Skip to main content
Base URL: https://router.flatkey.ai Text generation runs through POST /v1/chat/completions, which matches the OpenAI Chat Completions API exactly. Any OpenAI-compatible client works after you change the base URL.

No rewrite needed

Keep your existing request code and point base_url at https://router.flatkey.ai/v1.

One key, every model

Switch models by changing the model field. Nothing else changes.

Make your first call

Choose a model

List everything your account can reach and keep the text models:
Browse the same list with pricing, context length, and latency on the model directory. A practical starting point:

Stream the response

Set stream: true to receive tokens as they are produced:
Each chunk carries a partial delta instead of a complete message.

Call your own functions

Pass tool definitions and the model decides when to invoke them:
To finish the loop, append the assistant message, then one message per tool result keyed by tool_call_id, and send the whole thread back.
When a tool fires, finish_reason is tool_calls, not stop. Code that only checks for stop will drop the call silently.
Tool calling is a capability of the model, not of Flatkey. The GPT, Claude, Gemini, Qwen, DeepSeek, and GLM families support it. Image, video, and speech models ignore a tools array.

Force a JSON shape

Use response_format when you need to parse the answer:
{"type": "json_object"} also works when you only need valid JSON without a fixed schema.

Read token usage

Every response carries the counts you are billed on:
Different model families tokenize differently, so the same text costs a different number of tokens on different models. Use usage rather than estimating from character counts. Per-request cost also appears in Usage logs.

Troubleshooting

No available channel for model ... That model is not routable right now. Pick another id from /v1/models. Retrying the same model does not clear this. The response stops mid-sentence finish_reason is length. Raise max_tokens. Tool calls never fire Confirm the model supports tools, and check that tool_choice is not set to none.

Next steps

API reference

Every parameter and response field.

OpenAI SDK guide

Drop Flatkey into an existing OpenAI project.