Skip to content

API reference ​

CodingRouter is compatible with the official API formats of OpenAI, Anthropic and Google. The official SDKs work after changing the Base URL. Each API in this section has its own page, and the parameters and examples have been verified with real requests.

Basics ​

ItemValue
Base URLhttps://api.codingrouter.ai
Base URL for the OpenAI SDKhttps://api.codingrouter.ai/v1
Request formatJSON; multipart/form-data for image uploads
Maximum request body256 MB

API overview ​

CategoryAPIMethod and path
ChatChat CompletionsPOST /v1/chat/completions
ChatResponsesPOST /v1/responses
ChatClaude MessagesPOST /v1/messages
ChatGemini generateContentPOST /v1beta/models/{model}:generateContent
EmbeddingsEmbeddingsPOST /v1/embeddings
ImagesImage generationPOST /v1/images/generations
ImagesImage editsPOST /v1/images/edits
VideoVideo generationPOST /v1/videos, GET /v1/videos/{id}, GET /v1/videos/{id}/content
ModelsList modelsGET /v1/models, GET /v1beta/models

Authentication ​

Create a token (starting with sk-) in the console under Token management. The forms each API supports:

FormAPIs
Authorization: Bearer sk-...All APIs
x-api-key: sk-...Claude Messages, /v1/models
x-goog-api-key: sk-...Gemini API, /v1/models
URL parameter ?key=sk-...Gemini API, /v1/models

A token can only call models in its own group. See Tokens and groups.

Choosing an API format ​

The API format does not have to match the model vendor: all text models can be called through Chat Completions, Claude models also support Claude Messages, and Gemini models also support the native Gemini format. When you need a vendor's own features (Claude's prompt caching, Gemini's thinkingConfig, image and speech output), use the native format.

Streaming ​

All chat APIs support SSE streaming (Content-Type: text/event-stream):

APIHow to enableEnd marker
Chat Completions"stream": truedata: [DONE]
Responses"stream": trueevent: response.completed
Claude Messages"stream": trueevent: message_stop
GeminiCall :streamGenerateContent?alt=sse insteadConnection closes

For long-running requests, prefer streaming, or set the client timeout to 300 seconds or more.

The stream may contain heartbeat lines that start with a colon (such as : PING) to keep the connection alive. Official SDKs ignore them automatically. If you parse SSE yourself, skip these lines.

Errors ​

The error body follows the protocol format you call. For status codes and how to handle them, see Errors and retries.