Using Responses API
Use AnyRouter's Responses endpoint for agent and tool workflows with structured output items.
Use /api/v1/responses when you want tool calls and reasoning in one typed output array, which makes agent loops easier to track than chat deltas. It uses the same base URL and key (sk-ar-..., from the dashboard) as Chat Completions.
| Use case | Endpoint |
|---|---|
| Existing OpenAI chat app | Chat Completions |
| Anthropic Messages client | Messages |
| Agent or tool workflow | Responses |
| Model and price discovery | Models |
Minimal request
import OpenAI from "openai"
const client = new OpenAI({
baseURL: "https://anyrouter.dev/api/v1",
apiKey: process.env.ANYROUTER_API_KEY,
})
const response = await client.responses.create({
model: "openai/gpt-5.4-mini",
input: "Turn these notes into three action items.",
})
console.log(response.output_text)The same call over HTTP:
curl https://anyrouter.dev/api/v1/responses \
-H "Authorization: Bearer sk-ar-your-key" \
-H "Content-Type: application/json" \
-d '{"model": "openai/gpt-5.4-mini", "input": "Turn these notes into three action items."}'Tools
{
"model": "openai/gpt-5.4-mini",
"input": "Find the status of order 1234.",
"tools": [
{
"type": "function",
"name": "lookup_order",
"description": "Look up an order by id",
"parameters": {
"type": "object",
"properties": { "order_id": { "type": "string" } },
"required": ["order_id"]
}
}
],
"tool_choice": "auto"
}Routing preferences
Responses accepts the same provider object as Chat Completions, for example {"provider": {"sort": "latency", "allow_fallbacks": true, "max_price": {"prompt": "2.00", "completion": "8.00"}}}. See Provider Routing.
Troubleshooting
| Symptom | Fix |
|---|---|
output_text is empty after a tool call | The tool call is an item in output. Run the tool, append the result, and call again for the final text. |
AnyRouter routes requests to third-party models. Models and outputs are provided as is, with no warranty; you use them at your own risk. Disclaimer