Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.routing.run/llms.txt

Use this file to discover all available pages before exploring further.

POST /v1/messages accepts Anthropic Messages-style request bodies and routes them through the same routing chain as chat completions.
Do not use this as your default integration path. For apps and coding agents, prefer /v1/chat/completions.

Base URL

https://api.routing.run/v1
This endpoint is currently request-compatible, not full Anthropic SDK parity. The response returns content as a string and includes credits_charged, so some Anthropic SDK helpers will not deserialize it exactly.
Live checks against route/glm-5.1-precision, route/qwen3.6-plus, and route/kimi-k2.5 showed another limitation: some reasoning-oriented models can return an empty content string from /v1/messages even when output tokens are billed. If you need predictable assistant text for coding agents, prefer the OpenAI-compatible endpoint.

Quick setup

import os
import requests

response = requests.post(
    "https://api.routing.run/v1/messages",
    headers={
        "X-API-Key": os.environ["ROUTING_RUN_API_KEY"],
        "Content-Type": "application/json",
    },
    json={
        "model": "route/deepseek-v3.2",
        "max_tokens": 1024,
        "messages": [
            {"role": "user", "content": "Summarize risks in this dependency diff: ..."}
        ],
    },
)

print(response.json()["content"])

How it works

Anthropic-shaped requests are converted internally, run through the same routing chain as chat completions, then returned as a simplified message object.

Request

Response

{
  "id": "msg_1744701234567",
  "type": "message",
  "role": "assistant",
  "content": "- Supply chain: pinned lodash has a known advisory …",
  "model": "route/deepseek-v3.2",
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 220,
    "output_tokens": 180
  },
  "credits_charged": 0.003
}
content is a string (assistant text) in the wire JSON. credits_charged is a routing.run extension (float credits deducted for that call). The upstream internal id is not included in this JSON response (it is logged server-side).

Stop reasons

ValueMeaning
end_turnReturned by the current adapter for normal Anthropic-style responses, including some truncated cases
max_tokensDocumented Anthropic value, but not reliably surfaced by the current adapter

Error handling

See Authentication for plain-text + X-Error-Code handling (same middleware stack as chat).