curl
Call AnyRouter's OpenAI-compatible API from the terminal with curl, for quick tests, scripts and CI.
Any curl command that works against OpenAI works here with a new URL and key. Create a key (prefix sk-ar-) in the dashboard and export it:
export ANYROUTER_API_KEY="sk-ar-your-key-here"Chat request
curl https://anyrouter.dev/api/v1/chat/completions \
-H "Authorization: Bearer $ANYROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemini-3.5-flash",
"messages": [{"role": "user", "content": "Hello!"}]
}'A 200 with a choices array means it worked. A 401 means $ANYROUTER_API_KEY is missing or does not start with sk-ar-.
For a multi-turn chat, send the full messages array.
Stream
Add "stream": true and --no-buffer to receive server-sent events:
curl https://anyrouter.dev/api/v1/chat/completions \
-H "Authorization: Bearer $ANYROUTER_API_KEY" \
-H "Content-Type: application/json" \
--no-buffer \
-d '{"model": "anthropic/claude-sonnet-4-6", "messages": [{"role": "user", "content": "Count to 10, slowly."}], "stream": true}'Other calls
| Call | Command |
|---|---|
| List models | curl https://anyrouter.dev/api/v1/models -H "Authorization: Bearer $ANYROUTER_API_KEY" |
| Check credits | curl https://anyrouter.dev/api/v1/credits -H "Authorization: Bearer $ANYROUTER_API_KEY" |
| Health (no auth) | curl -A "my-status-probe/1.0" https://anyrouter.dev/api/v1/health |
To attribute usage to your project in app rankings, add -H "X-Title: My Script" -H "X-Source: my-script".
AnyRouter routes requests to third-party models. Models and outputs are provided as is, with no warranty; you use them at your own risk. Disclaimer