Responses and Messages

Use clients that speak the OpenAI Responses API or the Anthropic Messages API.

Some clients only speak the OpenAI Responses API or the Anthropic Messages API. AnonRouter accepts both and serves them through the same models, routing, limits, and billing as Chat Completions.

EndpointBase URL to configureAuthentication
POST /v1/responseshttps://api.anonrouter.ai/v1Authorization: Bearer
POST /v1/messageshttps://api.anonrouter.aix-api-key or Authorization: Bearer
POST /v1/messages/count_tokenshttps://api.anonrouter.aix-api-key or Authorization: Bearer

Both use compatibility mode, so the key needs OpenAI-compatible access and the same privacy tradeoff applies. Any chat model or router id from the catalog works on either endpoint, whoever created the model.

Responses

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.ANONROUTER_API_KEY!,
  baseURL: "https://api.anonrouter.ai/v1",
  maxRetries: 0,
});

const response = await client.responses.create({
  model: process.env.ANONROUTER_MODEL!,
  input: "Hello from AnonRouter",
  max_output_tokens: 1024,
  store: false,
});

console.log(response.output_text);

Nothing is stored, so every request carries the whole conversation. Send the earlier input and output items again on each turn, followed by the results of any tools your client ran.

FieldBehavior
store: true400 store_unsupported
previous_response_id400 previous_response_id_unsupported
conversation400 conversation_unsupported
background: true400 background_unsupported
includeOnly reasoning.encrypted_content is accepted, and no encrypted reasoning is returned
metadata, user, prompt_cache_keyAccepted and discarded

There is no endpoint to retrieve or delete a response by id.

Messages

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  apiKey: process.env.ANONROUTER_API_KEY!,
  baseURL: "https://api.anonrouter.ai",
  maxRetries: 0,
});

const message = await client.messages.create({
  model: process.env.ANONROUTER_MODEL!,
  max_tokens: 1024,
  messages: [{ role: "user", content: "Hello from AnonRouter" }],
});

for (const block of message.content) {
  if (block.type === "text") console.log(block.text);
}

Read the text blocks rather than the first block. A model that returns its reasoning places a thinking block before the text.

FieldBehavior
max_tokensRequired
top_k400, not supported
cache_controlAccepted as a hint and discarded
metadata.user_idAccepted and discarded
stop_sequencesApplied, but stop_reason can be end_turn and stop_sequence null when the provider does not report the match
thinking.budget_tokensSelects a low, medium, or high effort. It is not an exact token budget

count_tokens returns an estimate and is not billed. The final usage comes from the completed request.

Tools

Your client runs its own function tools. The tool calling limits apply to both endpoints.

Tools that run on the model vendor's side, such as web search, file search, or code execution, are skipped and the model answers without them. The response then names them in the x-anonrouter-ignored-tools header:

x-anonrouter-ignored-tools: web_search

Vendor tools that the client is expected to run, such as local_shell or bash, are refused with a 400 that names the tool. Define them as function tools instead.

Choosing a provider

The provider object is not accepted on these endpoints and returns a 400. Set provider rules for the workspace instead. See provider routing.

Streaming and billing

Set stream: true for either endpoint. A Responses stream ends with response.completed or response.incomplete, and a Messages stream ends with message_stop. Treat a stream that stops without one of these as incomplete, and check your usage before sending it again, because the first request may have been charged. The examples above turn off automatic SDK retries for the same reason.

Let your agent handle the setup

One prompt carries the entire setup.