La documentation est disponible en anglais.
Documentation / Anthropic-compatible
Create a message
POST/anthropic/v1/messages
Anthropic Messages API shape, converted to the TokenSaver pipeline and remapped back to an Anthropic message (or SSE when stream: true). max_tokens is required, as in the Anthropic contract.
Request highlights
model— preferprovider/model_id(e.g.anthropic/claude-sonnet-4-6) fromGET /anthropic/v1/models; omit to use the key’sdefault_modelmessages—user/assistant;contentis a string or a list of blocks (text,tool_use,tool_result). Inlinesystem/developerturns (sent by Claude Code) are hoisted to the top-levelsystemfieldsystem— string or list oftextblocks → merged into pipeline instructionsmax_tokens— required; Free plan output cap may applystream: true— Anthropic SSE events; see Tools & streamingtools,tool_choice— function calling (plan quotas may apply);top_p,top_k,metadataare accepted and ignored (phase 1)
Minimal curl
curl -sS "https://api.tokensaver.fr/anthropic/v1/messages" \
-H "x-api-key: $TS_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4-6",
"max_tokens": 256,
"messages": [{"role": "user", "content": "Hello"}]
}'
Anthropic Python SDK
from anthropic import Anthropic
client = Anthropic(
api_key="ts_...", # TokenSaver key, not the vendor key
base_url="https://api.tokensaver.fr/anthropic",
)
msg = client.messages.create(
model="anthropic/claude-sonnet-4-6",
max_tokens=256,
messages=[{"role": "user", "content": "Hello"}],
)
print(msg.content[0].text)
Response (non-stream)
Standard Anthropic message envelope. content is a text block followed, if any, by one or more tool_use blocks. stop_reason is one of end_turn, tool_use, max_tokens, stop_sequence.
{
"id": "msg_...",
"type": "message",
"role": "assistant",
"model": "anthropic/claude-sonnet-4-6",
"content": [{ "type": "text", "text": "Hello! How can I help?" }],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": { "input_tokens": 12, "output_tokens": 34 }
}
Content blocks (agent loop)
text→ message texttool_use(assistant) → internal tool calls (id→ tool_call id,inputobject → JSON arguments)tool_result(user) → onerole: toolmessage per result (tool_use_id→tool_call_id)image/thinkingblocks: not supported in phase 1 (ignored)