Reference
One endpoint, POST /v1/chat/completions. The request is the OpenAI request; the response adds three fields of our own.
Drop-in
Point your OpenAI SDK at a new base URL. Same calls, no rewrites.
- base_url = "https://api.openai.com/v1"
+ base_url = "https://api.reka.ai/v1"
- api_key = os.environ["OPENAI_API_KEY"]
+ api_key = os.environ["REKA_API_KEY"]
- Chat Completions. the same /v1/chat/completions request and response shape you already send.
- Streaming. token-by-token server-sent events, with usage totals on the final chunk.
- Prompt caching. repeated prefixes are cached automatically and billed at the cache-read rate.
Request
modelrequired | string | An id from the models table. No namespace prefix. |
messagesrequired | Message[] | Roles system, user, assistant, tool. |
stream | boolean | Server-sent events; usage totals arrive on the final chunk. |
max_tokens | integer | Capped by the model's max output length. |
temperature | number | 0–2. Supported on every model. |
top_p | number | Nucleus sampling. Supported on every model. |
stop | string | string[] | Up to 4 sequences. |
tools | Tool[] | Native function calling on every model except reka-flash-3. |
response_format | object | json_object and json_schema on deepseek4-flash, reka-flash-3, reka-edge-2603. |
logprobs | boolean | deepseek4-flash only. |
seed | integer | glm5.2 only. |
type Message = {
role: "system" | "user" | "assistant" | "tool";
content: string;
};
type ChatRequest = {
model: string;
messages: Message[];
stream?: boolean;
max_tokens?: number;
temperature?: number;
top_p?: number;
stop?: string | string[];
tools?: Tool[];
response_format?: { type: "json_object" | "json_schema" };
logprobs?: boolean;
};Response
The OpenAI response shape throughout, except for three fields of our own.
message.reasoning_content | string | null | Thinking trace on reasoning models; null elsewhere. |
usage.reasoning_tokens | integer | Inside completion_tokens, not billed twice. |
metadata.weight_version | string | Which checkpoint served the request. |
{
"id": "ee405e3d0af64c718248dc2776c3afc7",
"object": "chat.completion",
"created": 1787725814,
"model": "deepseek4-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Air scatters blue light most.",
"reasoning_content": null,
"tool_calls": null
},
"logprobs": null,
"finish_reason": "stop",
"matched_stop": 1
}
],
"usage": {
"prompt_tokens": 13,
"total_tokens": 55,
"completion_tokens": 42,
"prompt_tokens_details": null,
"reasoning_tokens": 0
},
"metadata": {
"weight_version": "default"
}
}Errors
Errors come back in the OpenAI error envelope, so existing handling works unchanged.
401 | Missing or revoked key. Check the Authorization header. |
404 | Unknown model id. The ids are unprefixed, so reka/glm5.2 is a 404. |
422 | A parameter the model does not support, such as seed outside glm5.2. |
429 | Rate or capacity limit. Retry with backoff; the body names which. |
5xx | Ours. Retry idempotently and send us the response id. |