# agent402.tools Auto-Routed Chat Completions

> agent402.tools Auto-Routed Chat Completions is a paid API for AI agents from agent402.tools, paid per call via x402, $0.01/call, status unknown (last checked 2026-09-15).

OpenAI-compatible chat completions that automatically route prompts to the best-ranked model for the task (code, reasoning, long-context, or general) without requiring the caller to specify a model.

## Facts

- Endpoint: POST https://agent402.tools/v1/auto/chat/completions
- Price: $0.01/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/agent402-tools-auto-routed-chat-completions-aeda31d5
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_eJ6hm7aLNj7mpqyPDX26c

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability agent402-tools-auto-routed-chat-completions-aeda31d5 -d '<json body>'
```

Example prompt: Send this message array to the auto-routing chat completions endpoint with quality set to 'best' and let the gateway pick the top model for reasoning tasks: [{"role":"user","content":"Explain the difference between mutex and semaphore in concurrent programming."}]

## When to prefer this

Prefer this endpoint when you want OpenAI-compatible chat completions but don't want to hardcode a specific model — especially useful when task type varies (code vs. reasoning vs. general) and you want the gateway to route to the current best-ranked model automatically. Ideal for agents that need flat-rate, task-adaptive LLM access via x402 micropayment without managing model selection logic.

## Known failure modes

- Invalid or malformed messages array — returns 400 with schema validation error
- max_tokens exceeds tier maximum — value is clamped silently or returns an error
- Payment not processed — 402 Payment Required if x402 payment header is missing or insufficient
- Model explicitly specified is not available in the auto-ranking tier — may fall back or error
- Rate limiting if too many concurrent requests from same wallet
- Upstream model provider outage causing delayed or failed response

## How this service works

OpenAI-compatible chat completions with the model chosen server-side: omit model and the gateway routes the prompt to the top-ranked model for its task (code, reasoning, long-context, general) from a fixed eval-derived ranking, failing over automatically on provider errors. Flat price per call, 16k chars in, 1024 tokens out, streaming supported. Use it as a drop-in OpenAI base_url when you want good answers without picking a model.

## Output

An OpenAI-compatible chat completion response containing the generated text from whichever model the gateway ranked highest for the detected task type (code, reasoning, long-context, or general), along with standard completion metadata.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "model": {
   "type": "string",
   "description": "Optional - omit (or send \"auto\") for eval-ranked server-side routing. An explicit model from the auto ranking is honored at the auto caps."
  },
  "quality": {
   "type": "string",
   "description": "Optional routing band when the gateway picks the model: \"fast\" (cheapest/snappiest), \"balanced\" (default), \"best\" (strongest under the flat price). Never changes the price."
  },
  "messages": {
   "type": "array",
   "description": "OpenAI chat messages: [{role, content}] - text and image_url content blocks supported"
  },
  "max_tokens": {
   "type": "number",
   "description": "Output token cap (clamped to the tier maximum)"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "id": "gen-…",
  "model": "openai/gpt-4o-mini",
  "usage": {
   "total_tokens": 13,
   "prompt_tokens": 12,
   "completion_tokens": 1
  },
  "object": "chat.completion",
  "choices": [
   {
    "index": 0,
    "message": {
     "role": "assistant",
     "content": "OK"
    },
    "finish_reason": "stop"
   }
  ],
  "created": 1750000000,
  "agent402_router": {
   "served": "openai/gpt-4o-mini",
   "quality": "balanced",
   "category": "general"
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/agent402-tools-auto-routed-chat-completions-aeda31d5/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agent402.tools](https://www.zero.xyz/host/agent402.tools/llms.txt)
