# x-router.ai Chat Completions

> x-router.ai Chat Completions is a paid API for AI agents from api.x-router.ai, paid per call via x402, $0.001/call, status unknown (last checked 2026-09-15).

Routes AI chat completion requests to multiple LLM providers (OpenAI, Anthropic, etc.) via a unified API, billed per-call via x402 micropayments

## Facts

- Endpoint: POST https://api.x-router.ai/v1/chat/completions
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/api-x-router-ai-ca24d984
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_l9qdwGoU5OC7Y2XsKO46q

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 api-x-router-ai-ca24d984 -d '<json body>'
```

Example prompt: Using the x-router.ai chat completions endpoint with anthropic/claude-3.5-sonnet, send this conversation and give me a response: system prompt 'You are a helpful assistant', user message 'Explain the difference between supervised and unsupervised learning in two sentences', with temperature 0.7 and max 300 tokens.

## When to prefer this

Choose this endpoint when you need a unified LLM gateway that supports multiple providers (OpenAI, Anthropic, etc.) under a single API with x402 micropayment billing. Ideal for agents that need to switch models dynamically or avoid managing separate API keys for each provider. Particularly useful in x402-native payment environments where per-call USDC billing is preferred over subscription keys.

## Known failure modes

- Payment not included or insufficient — returns x402 payment required response with accepted payment details
- Invalid model string format — model must be in 'provider/model' format like 'openai/gpt-4o-mini'
- Messages array missing or malformed — required field, returns validation error
- Upstream provider unavailable — routing failure if target provider is down
- Temperature out of range — must be 0-2
- max_tokens out of range — must be 1-128000
- Streaming not supported in all contexts — stream:true may require SSE-compatible client

## How this service works

AI Chat Completion

## Output

Returns a standard OpenAI-compatible chat completion response including the assistant's generated message content, the model used, and token usage statistics (prompt tokens, completion tokens, total tokens).

## Example request

```json
{
 "model": "openai/gpt-4o-mini",
 "stream": false,
 "messages": [
  {
   "role": "system",
   "content": "You are a helpful assistant."
  },
  {
   "role": "user",
   "content": "Explain the difference between supervised and unsupervised learning in two sentences."
  }
 ],
 "max_tokens": 300,
 "temperature": 0.7
}
```

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "messages"
 ],
 "properties": {
  "model": {
   "type": "string",
   "description": "The AI model to use, in 'provider/model' format (e.g. 'openai/gpt-4o-mini', 'anthropic/claude-3.5-sonnet')"
  },
  "stream": {
   "type": "boolean",
   "description": "Enable streaming response"
  },
  "messages": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "role",
     "content"
    ],
    "properties": {
     "role": {
      "enum": [
       "system",
       "user",
       "assistant"
      ],
      "type": "string"
     },
     "content": {
      "type": "string"
     }
    }
   },
   "description": "Array of message objects with role and content"
  },
  "max_tokens": {
   "type": "number",
   "description": "Maximum tokens in response, 1-128000"
  },
  "temperature": {
   "type": "number",
   "description": "Temperature for response randomness, 0-2"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "x402Version",
  "accepts",
  "error",
  "_x402",
  "_paymentRequired",
  "_wwwAuthenticate"
 ],
 "properties": {
  "_x402": {
   "type": "boolean"
  },
  "error": {
   "type": "string"
  },
  "accepts": {
   "type": "array",
   "items": {
    "type": "object",
    "required": [
     "scheme",
     "network",
     "maxAmountRequired",
     "resource",
     "description",
     "mimeType",
     "outputSchema",
     "payTo",
     "maxTimeoutSeconds",
     "asset",
     "extra"
    ],
    "properties": {
     "asset": {
      "type": "string"
     },
     "extra": {
      "type": "object",
      "required": [
       "name",
       "version"
      ],
      "properties": {
       "name": {
        "type": "string"
       },
       "version": {
        "type": "string"
       }
      }
     },
     "payTo": {
      "type": "string"
     },
     "scheme": {
      "type": "string"
     },
     "network": {
      "type": "string"
     },
     "mimeType": {
      "type": "string"
     },
     "resource": {
      "type": "string"
     },
     "description": {
      "type": "string"
     },
     "outputSchema": {
      "type": "object",
      "required": [
       "input",
       "output"
      ],
      "properties": {
       "input": {
        "type": "object",
        "required": [
         "type",
         "method",
         "discoverable",
         "bodyType",
         "bodyFields"
        ],
        "properties": {
         "type": {
          "type": "string"
         },
         "method": {
          "type": "string"
         },
         "bodyType": {
          "type": "string"
         },
         "bodyFields": {
          "type": "object",
          "required": [
           "messages",
           "model",
           "max_tokens",
           "temperature",
           "stream"
          ],
          "properties": {
           "model": {
            "type": "object",
            "required": [
             "type",
             "description"
            ],
            "properties": {
             "type": {
              "type": "string"
             },
             "description": {
              "type": "string"
             }
            }
           },
           "stream": {
            "type": "object",
            "required": [
             "type",
             "description"
            ],
            "properties": {
             "type": {
              "type": "string"
             },
             "description": {
         
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/api-x-router-ai-ca24d984/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.x-router.ai](https://www.zero.xyz/host/api.x-router.ai/llms.txt)
