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
| Item | Value |
|---|---|
| Base URL | https://api.codingrouter.ai |
| Base URL for the OpenAI SDK | https://api.codingrouter.ai/v1 |
| Request format | JSON; multipart/form-data for image uploads |
| Maximum request body | 256 MB |
API overview
| Category | API | Method and path |
|---|---|---|
| Chat | Chat Completions | POST /v1/chat/completions |
| Chat | Responses | POST /v1/responses |
| Chat | Claude Messages | POST /v1/messages |
| Chat | Gemini generateContent | POST /v1beta/models/{model}:generateContent |
| Embeddings | Embeddings | POST /v1/embeddings |
| Images | Image generation | POST /v1/images/generations |
| Images | Image edits | POST /v1/images/edits |
| Video | Video generation | POST /v1/videos, GET /v1/videos/{id}, GET /v1/videos/{id}/content |
| Models | List models | GET /v1/models, GET /v1beta/models |
Authentication
Create a token (starting with sk-) in the console under Token management. The forms each API supports:
| Form | APIs |
|---|---|
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):
| API | How to enable | End marker |
|---|---|---|
| Chat Completions | "stream": true | data: [DONE] |
| Responses | "stream": true | event: response.completed |
| Claude Messages | "stream": true | event: message_stop |
| Gemini | Call :streamGenerateContent?alt=sse instead | Connection 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.
