# Using Responses API

> Use AnyRouter's Responses endpoint for agent and tool workflows with structured output items.


# Using the Responses API

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](https://anyrouter.dev/dashboard/keys)) as Chat Completions.

| Use case | Endpoint |
|---|---|
| Existing OpenAI chat app | [Chat Completions](/api-reference/chat-completions) |
| Anthropic Messages client | [Messages](/api-reference/messages) |
| Agent or tool workflow | [Responses](/api-reference/responses) |
| Model and price discovery | [Models](/api-reference/models) |

## 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](/guides/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. |


## Related

- [Responses API](/docs/api-reference/responses.md)
- [Smart Routing](/docs/features/routing.md)
- [API Overview](/docs/api-reference/overview.md)
- [Provider Routing](/docs/guides/provider-routing.md)
