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

modelrequiredstringAn id from the models table. No namespace prefix.
messagesrequiredMessage[]Roles system, user, assistant, tool.
streambooleanServer-sent events; usage totals arrive on the final chunk.
max_tokensintegerCapped by the model's max output length.
temperaturenumber0–2. Supported on every model.
top_pnumberNucleus sampling. Supported on every model.
stopstring | string[]Up to 4 sequences.
toolsTool[]Native function calling on every model except reka-flash-3.
response_formatobjectjson_object and json_schema on deepseek4-flash, reka-flash-3, reka-edge-2603.
logprobsbooleandeepseek4-flash only.
seedintegerglm5.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_contentstring | nullThinking trace on reasoning models; null elsewhere.
usage.reasoning_tokensintegerInside completion_tokens, not billed twice.
metadata.weight_versionstringWhich 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.

401Missing or revoked key. Check the Authorization header.
404Unknown model id. The ids are unprefixed, so reka/glm5.2 is a 404.
422A parameter the model does not support, such as seed outside glm5.2.
429Rate or capacity limit. Retry with backoff; the body names which.
5xxOurs. Retry idempotently and send us the response id.