API
Anthropic format
POST https://tokenarmy.shop/v1/messages is the native Anthropic format. Request body and response are unchanged—you're calling Anthropic's API directly, just through TokenArmy's gateway.
Non-streaming
# pip install anthropic import os import anthropic client = anthropic.Anthropic( base_url="https://tokenarmy.shop", api_key=os.environ["TOKENARMY_API_KEY"], # sk-ta-xxxx ) message = client.messages.create( model="claude-sonnet-5-5", max_tokens=1024, messages=[{"role": "user", "content": "Hello"}], ) print(message.content[0].text)
Streaming
Set the stream header; the gateway returns Server-Sent Events.
curl https://tokenarmy.shop/v1/messages -H "Authorization: Bearer $TOKENARMY_API_KEY" -H "Content-Type: application/json" -H "anthropic-version: 2023-06-01" -d '{"model":"claude-sonnet-5-5","stream":true,"max_tokens":100,"messages":[{"role":"user","content":"Hi"}]}'
For long outputs,
"stream": true is recommended: data arrives as it is generated. Non-streaming requests are not cut off for taking long: this site is accelerated by Cloudflare, which waits at most 125 seconds for a response to start, so a non-streaming request still generating after 30 seconds gets status 200 and its headers first, then a space every 15 seconds to keep the connection alive, then the complete JSON (whitespace before JSON does not affect parsing). If it fails after that point, the status is still 200 and the body is a JSON error. What was generated is billed as usual, exactly as for streaming.Vision (image input)
Supported models accept images. Use the Anthropic format:
{
"model": "claude-sonnet-5-5",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/jpeg",
"data": "base64-encoded-image"
}
},
{
"type": "text",
"text": "What is this image?"
}
]
}
]
}