API Reference
Complete API documentation for TokenHub
API Specification
TokenHub is fully compatible with the OpenAI API specification. Only the Base URL needs to be changed.
| Item | Value |
|---|---|
| Base URL | https://hubwave.ai/v1 |
| Auth | Authorization: Bearer sk-xxxxx |
| Content-Type | application/json |
Chat Completions
POST /v1/chat/completions
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | ✅ | Model name, e.g. gpt-4o |
| messages | array | ✅ | Chat messages |
| stream | boolean | ❌ | Streaming response |
| temperature | number | ❌ | 0~2, default 1 |
| max_tokens | integer | ❌ | Max output tokens |
| tools | array | ❌ | Function calling tools |
Example
curl https://hubwave.ai/v1/chat/completions \
-H "Authorization: Bearer sk-xxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-3-5-sonnet-20241022",
"messages": [{"role": "user", "content": "Hello"}],
"stream": true
}'
Embeddings
POST /v1/embeddings
curl https://hubwave.ai/v1/embeddings \
-H "Authorization: Bearer sk-xxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "text-embedding-3-small",
"input": "Hello world"
}'
Error Codes
| Code | Meaning |
|---|---|
| 401 | Invalid API Key or insufficient quota |
| 429 | Rate limit, please retry later |
| 500 | Upstream error, auto-retried |
| 503 | Channel unavailable |