Messages (Anthropic)
POST /v1/messages — for tools that speak Anthropic's format.
POST
https://iranrouter.com/v1/messagesSome tools speak Anthropic's Messages format instead of OpenAI's. You do not need an adapter — the same origin answers this path too, with the same ir- key.
curl https://iranrouter.com/v1/messages \ -H "Authorization: Bearer ir-..." \ -H "Content-Type: application/json" \ -d '{ "model": "anthropic/claude-sonnet-4.5", "max_tokens": 512, "messages": [{"role": "user", "content": "سلام"}] }'
What is translated
- system as a string or blocks, and
text/image/tool_use/tool_resultblocks - Tools both ways:
tools→tool_usein the response, andfinish_reason→stop_reason - Stream events in Anthropic's event shape.
/v1/messages/count_tokens works and is free — no upstream call is made. The number is an estimate, computed with the same arithmetic the wallet hold uses; fine for context management, not an exact tokenizer.If the choice is yours, chat/completions is the primary and more complete surface.