QuickstartAPI ReferenceTutorials

Public docs for evaluation and integration.

Reference

API Reference

ToksHub is OpenAI-compatible. Most teams can keep their request shape and switch to a new base URL.

Base URL

https://api.tokshub.com/v1

Authentication

Pass your API key as a Bearer token in every request:

Authorization: Bearer sk-your-key

Endpoints

Chat & Text Completions

POST
/v1/chat/completionsChat completions — primary endpoint
POST
/v1/completionsLegacy text completions

Responses API

Stateful multi-turn conversations.

POST
/v1/responsesCreate a response
GET
/v1/responsesList responses
GET
/v1/responses/:idRetrieve a response
DELETE
/v1/responses/:idDelete a response
POST
/v1/responses/:id/cancelCancel in-progress response

Messages (Anthropic Native)

Use Claude models with the Anthropic Messages format directly.

POST
/v1/messagesAnthropic-compatible Messages endpoint

Embeddings

POST
/v1/embeddingsCreate text embeddings
POST
/v1/engines/:model/embeddingsLegacy path (OpenAI v1 compat)

Rerank

POST
/v1/rerankRerank documents by relevance
POST
/v2/rerankV2 endpoint (Cohere-compatible)

Images

Requires a channel with image generation capability.

POST
/v1/images/generationsGenerate images from text
POST
/v1/images/editsEdit an existing image

Audio

Requires a channel with audio capability.

POST
/v1/audio/speechText-to-speech (TTS)
POST
/v1/audio/transcriptionsAudio to text (Whisper)
POST
/v1/audio/translationsTranscribe & translate to English

Video

Requires a channel with video generation capability.

POST
/v1/videosSubmit a video task
GET
/v1/videosList video tasks
GET
/v1/videos/:idGet task status
GET
/v1/videos/:id/contentDownload completed video
DELETE
/v1/videos/:idDelete a video task

Moderation

POST
/v1/moderationsClassify text for policy violations

Realtime

GET
/v1/realtimeWebSocket for real-time sessions

MCP (Model Context Protocol)

POST
/mcpMCP proxy — route tool calls

Models

GET
/v1/modelsList all available models
GET
/v1/models/:modelRetrieve model details

Special Endpoints

POST
/api/paas/v4/layout_parsingZhipu OCR / document parsing

Special Compatibility

Claude Code Path Normalization

Claude Code may send Messages API requests through different path prefixes. ToksHub rewrites all of the following to POST /v1/messages:

/openai/v1/messages/v1/v1/messages/openai/v1/v1/messages/api/v1/v1/messages

No client-side configuration required.

API Format Auto-Detection

If a request body is sent to the wrong endpoint, for example a Responses API payload to /v1/chat/completions),ToksHub detects the mismatch and automatically redirects to the correct endpoint.

Rate Limits

Limits are enforced per IP address. Additional per-key limits may apply — see Dashboard.

EndpointRate LimitBurst
/v1/* AI calls60 req/min20
/api/* General60 req/min10
/api/oauth/* OAuth10 req/min5
/api/user/register5 req/min2
Streaming timeout300 seconds
Max request body32 MB

Error Codes

401Invalid or missing API key
402Insufficient balance — top up at Dashboard
429Rate limit exceeded — retry after a short delay
503Upstream provider unavailable — auto-failover in progress
API Reference — ToksHub