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.
| Endpoint | Base URL to configure | Authentication |
|---|---|---|
POST /v1/responses | https://api.anonrouter.ai/v1 | Authorization: Bearer |
POST /v1/messages | https://api.anonrouter.ai | x-api-key or Authorization: Bearer |
POST /v1/messages/count_tokens | https://api.anonrouter.ai | x-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.
| Field | Behavior |
|---|---|
store: true | 400 store_unsupported |
previous_response_id | 400 previous_response_id_unsupported |
conversation | 400 conversation_unsupported |
background: true | 400 background_unsupported |
include | Only reasoning.encrypted_content is accepted, and no encrypted reasoning is returned |
metadata, user, prompt_cache_key | Accepted 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.
| Field | Behavior |
|---|---|
max_tokens | Required |
top_k | 400, not supported |
cache_control | Accepted as a hint and discarded |
metadata.user_id | Accepted and discarded |
stop_sequences | Applied, but stop_reason can be end_turn and stop_sequence null when the provider does not report the match |
thinking.budget_tokens | Selects 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_searchVendor 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.