API
Responses API
The OpenAI-compatible /v1/responses endpoint (stateless subset).
POST /v1/responses implements the OpenAI Responses API surface that agents and tools like Codex use. TokenRouter’s implementation is stateless: each call carries its full input.
Supported subset
inputas a string or an array of items (message,function_call,function_call_output).instructions,tools,tool_choice,temperature,max_output_tokens,stream.- Streaming via SSE with typed events (
response.output_text.delta, …).
Not supported (stateless):
previous_response_id, store, and server-side conversation state. Send the full history in input on every call. Built-in OpenAI tools (web search, file search, code interpreter) are not proxied.Request
bash
curl https://api.tokenrouter.io/v1/responses \
-H "Authorization: Bearer tr_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5-mini",
"instructions": "You are a terse assistant.",
"input": "List three ways to cut LLM costs."
}'Response
json
{
"id": "resp_7d2f90aa",
"object": "response",
"created_at": 1754400000,
"model": "openai/gpt-5-mini",
"status": "completed",
"output": [
{
"type": "message",
"role": "assistant",
"content": [
{"type": "output_text", "text": "1. Route to cheaper models... 2. Cap budgets... 3. Cache aggressively."}
]
}
],
"usage": {"input_tokens": 21, "output_tokens": 34, "total_tokens": 55}
}Function calling
Function round-trips use function_call and function_call_output items in input:
json
{
"model": "openai/gpt-5-mini",
"tools": [
{
"type": "function",
"name": "get_weather",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
],
"input": [
{"role": "user", "content": "Weather in Berlin?"},
{
"type": "function_call",
"call_id": "call_abc123",
"name": "get_weather",
"arguments": "{\"city\": \"Berlin\"}"
},
{
"type": "function_call_output",
"call_id": "call_abc123",
"output": "{\"temp_c\": 21, \"conditions\": \"sunny\"}"
}
]
}Works with any routed model, including auto — TokenRouter translates to the provider’s native format under the hood.