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 caseEndpoint
Existing OpenAI chat appChat Completions
Anthropic Messages clientMessages
Agent or tool workflowResponses
Model and price discoveryModels

Minimal request

typescript
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:

bash
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

json
{
  "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

SymptomFix
output_text is empty after a tool callThe 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