Messages API
Call POST /v1/messages on OneProvider with the native Anthropic request shape: system prompts, tool use, images and prompt caching all work.
Anthropic-native endpoint. The same request and response shape as api.anthropic.com; tool_choice is normalized, and temperature, top_p and top_k are not applied on Claude 5.x.
All models, capabilities, and prices Documentation index for AI agents:https://oneprovider.dev/docs/llms.txt Request
httpPOST https://api.oneprovider.dev/v1/messages
x-api-key: sk-...
anthropic-version: 2023-06-01
content-type: application/json
{
"model": "claude-sonnet-5-5",
"max_tokens": 1024,
"system": "You are a concise assistant.",
"messages": [
{"role": "user", "content": "Why is the sky blue?"}
]
} Request body
| Field | Type | Required | Notes |
|---|---|---|---|
model | string | yes | One of the supported model IDs (Claude allowlist on /v1/messages) |
messages | array | yes | {role, content} pairs |
max_tokens | int | yes | Hard cap on output. Thinking tokens count against it, so leave Claude 5.x models room (1024 or more). |
system | string | no | System prompt |
temperature | 0.0–1.0 | no | Leave unset on Claude 5.x: these models take no custom sampling values, so the gateway ignores them. Out-of-range values may still return 400. |
top_p | 0.0–1.0 | no | Leave unset on Claude 5.x: these models take no custom sampling values, so the gateway ignores them. Out-of-range values may still return 400. |
top_k | int | no | Leave unset on Claude 5.x: these models take no custom sampling values, so the gateway ignores them. Out-of-range values may still return 400. |
stop_sequences | array | no | |
stream | bool | no | See Streaming |
tools | array | no | See Tool use |
tool_choice | object | no | Normalized — see tools page |
Prompt caching
Mark up to four cache breakpoints with cache_control: {"type": "ephemeral"} on text or system blocks. A cache lives 5 minutes; add "ttl": "1h" for one hour, at a higher write rate. Cache reads are billed at 10% of the input rate or less, depending on the model (the response reports cache_read_input_tokens in usage).
{
"model": "claude-sonnet-5-5",
"max_tokens": 1024,
"system": [
{
"type": "text",
"text": "Long stable system prompt that should be cached...",
"cache_control": {"type": "ephemeral"}
}
],
"messages": [{"role": "user", "content": "Question 1"}]
} Response
json{
"id": "msg_01XYZ...",
"type": "message",
"role": "assistant",
"model": "claude-sonnet-5-5",
"content": [
{"type": "text", "text": "Rayleigh scattering — short wavelengths..."}
],
"stop_reason": "end_turn",
"usage": {
"input_tokens": 48,
"output_tokens": 92,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0
}
} Anthropic compatibility The request and response shape follow the Anthropic Messages API. If your existing code calls api.anthropic.com today, the only required change is base_url. Quick answers
Which base URL do I use?
Claude Code and Anthropic SDKs use https://api.oneprovider.dev. OpenAI SDKs and OpenAI-compatible clients use https://api.oneprovider.dev/v1. One key works behind both; the model list is on the models page ; rates are on the pricing page .
How do I authenticate?
Send the raw sk-… key in x-api-key or Authorization: Bearer: one of them, never both. Keep the key in an environment variable, not in a file that gets committed. More on authentication .
Where do I get a key?
Open your cabinet in the Telegram bot @oneprovider_robot or at app.oneprovider.dev, top up the balance and press “Issue a key”. Each key can carry its own spend limit. Cabinet & API keys .
What do 401, 404 and 429 mean?
401: the key is missing, mistyped or sent in the wrong header; paste the whole key without quotes or spaces. 404: usually a wrong base URL, for example a missing or doubled /v1. 429 with “Insufficient balance”: the cabinet balance or the key’s spend limit is used up, so top up instead of retrying; any other 429 is a rate limit, so wait for Retry-After. Details: error codes and troubleshooting .
Why do streams cut off or reset?
VPN and VLESS proxies often buffer SSE or break HTTP/2 negotiation. OneProvider has no regional restrictions and does not buffer streams, so turn the proxy off and retry.
Where do I ask if this is not enough?
Message @Oneproviderhelpbot on Telegram or open “Support” in the web cabinet, with the HTTP status code and the exact error message. How support works .
Last updated: 2026-11-28 Found a bug? @Oneproviderhelpbot