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/v1Authentication
Pass your API key as a Bearer token in every request:
Authorization: Bearer sk-your-keyEndpoints
Chat & Text Completions
/v1/chat/completionsChat completions — primary endpoint/v1/completionsLegacy text completionsResponses API
Stateful multi-turn conversations.
/v1/responsesCreate a response/v1/responsesList responses/v1/responses/:idRetrieve a response/v1/responses/:idDelete a response/v1/responses/:id/cancelCancel in-progress responseMessages (Anthropic Native)
Use Claude models with the Anthropic Messages format directly.
/v1/messagesAnthropic-compatible Messages endpointEmbeddings
/v1/embeddingsCreate text embeddings/v1/engines/:model/embeddingsLegacy path (OpenAI v1 compat)Rerank
/v1/rerankRerank documents by relevance/v2/rerankV2 endpoint (Cohere-compatible)Images
Requires a channel with image generation capability.
/v1/images/generationsGenerate images from text/v1/images/editsEdit an existing imageAudio
Requires a channel with audio capability.
/v1/audio/speechText-to-speech (TTS)/v1/audio/transcriptionsAudio to text (Whisper)/v1/audio/translationsTranscribe & translate to EnglishVideo
Requires a channel with video generation capability.
/v1/videosSubmit a video task/v1/videosList video tasks/v1/videos/:idGet task status/v1/videos/:id/contentDownload completed video/v1/videos/:idDelete a video taskModeration
/v1/moderationsClassify text for policy violationsRealtime
/v1/realtimeWebSocket for real-time sessionsMCP (Model Context Protocol)
/mcpMCP proxy — route tool callsModels
/v1/modelsList all available models/v1/models/:modelRetrieve model detailsSpecial Endpoints
/api/paas/v4/layout_parsingZhipu OCR / document parsingSpecial 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/messagesNo 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.
| Endpoint | Rate Limit | Burst |
|---|---|---|
/v1/* AI calls | 60 req/min | 20 |
/api/* General | 60 req/min | 10 |
/api/oauth/* OAuth | 10 req/min | 5 |
/api/user/register | 5 req/min | 2 |
| Streaming timeout | 300 seconds | |
| Max request body | 32 MB | |
Error Codes
401Invalid or missing API key402Insufficient balance — top up at Dashboard429Rate limit exceeded — retry after a short delay503Upstream provider unavailable — auto-failover in progress