Examples¶
A few worked end-to-end recipes. All examples use environment variables — never paste a real key.
Default auto-router¶
export SMART_GATEWAY_BASE_URL="https://smart-openrounter.bee1x.one"
export SMART_GATEWAY_API_KEY="$YOUR_GATEWAY_KEY"
curl -sS "$SMART_GATEWAY_BASE_URL/v1/chat/completions" \
-H "Authorization: Bearer $SMART_GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "smart-router",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain HMAC in one paragraph."}
],
"max_tokens": 200
}'
Force Pro for a hard task¶
curl -sS "$SMART_GATEWAY_BASE_URL/v1/chat/completions" \
-H "Authorization: Bearer $SMART_GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "smart-router-pro",
"messages": [
{"role": "user", "content": "[reasoning:high] Design a token-bucket rate limiter with per-tenant quotas."}
],
"max_tokens": 600
}'
Force Flash for a cheap task¶
curl -sS "$SMART_GATEWAY_BASE_URL/v1/chat/completions" \
-H "Authorization: Bearer $SMART_GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "smart-router-flash",
"messages": [{"role": "user", "content": "Rename foo to bar in this function."}],
"max_tokens": 200
}'
Streaming¶
curl -sN "$SMART_GATEWAY_BASE_URL/v1/chat/completions" \
-H "Authorization: Bearer $SMART_GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "smart-router-flash",
"stream": true,
"messages": [{"role": "user", "content": "Walk me through merge sort."}],
"max_tokens": 400
}'
Tool calls (OpenAI shape)¶
The gateway forwards tool definitions to OpenRouter unchanged.
curl -sS "$SMART_GATEWAY_BASE_URL/v1/chat/completions" \
-H "Authorization: Bearer $SMART_GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "smart-router",
"messages": [{"role": "user", "content": "What is the weather in Tokyo?"}],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"]
}
}
}],
"tool_choice": "auto"
}'
Multi-turn coding session¶
Send a real session ID and goal ID so the gateway can keep budget and runtime-evidence counters across requests:
curl -sS "$SMART_GATEWAY_BASE_URL/v1/chat/completions" \
-H "Authorization: Bearer $SMART_GATEWAY_API_KEY" \
-H "X-Smart-Gateway-Session: proj-A-2026-08-23" \
-H "X-Smart-Gateway-Goal: fix-flaky-test" \
-H "X-Task-Id: task-17" \
-H "Content-Type: application/json" \
-d '{
"model": "smart-router",
"messages": [
{"role": "user", "content": "Make this test deterministic."},
{"role": "assistant", "content": "Let me look at the timestamps."},
{"role": "tool", "tool_call_id": "t1", "content": "FAIL: timestamps differ by 12 ms"}
]
}'
Dry-run a routing decision¶
Don't talk to OpenRouter at all — ask the gateway what it would do:
curl -sS "$SMART_GATEWAY_BASE_URL/v1/route/decision" \
-H "Authorization: Bearer $SMART_GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"task": {
"task_id": "t1",
"goal_id": "g1",
"kind": "AUTH",
"instruction": "audit the refresh-token rotation logic",
"sensitive": true,
"risk_level": "HIGH",
"blast_radius": "HIGH"
},
"runtime": {
"attempts": 1,
"same_error_count": 1,
"files_touched": 6,
"tool_depth": 4
}
}'
Returns:
{
"task_id": "t1",
"action": "ROUTE",
"model": "deepseek_v4_pro",
"purpose": "EXECUTE",
"cause": "hard_pro_rule",
"score": 50.0,
"confidence": 0.98,
"hard_rule": true,
"evidence": ["task_kind=AUTH", "risk=HIGH"],
"policy_version": "1"
}
Force Scout on a non-sensitive task¶
curl -sS "$SMART_GATEWAY_BASE_URL/v1/chat/completions" \
-H "Authorization: Bearer $SMART_GATEWAY_API_KEY" \
-H "X-Scout: true" \
-H "Content-Type: application/json" \
-d '{
"model": "smart-router",
"messages": [{"role": "user", "content": "Should I use a tree or a hashmap for this?"}],
"metadata": {"sensitive": false}
}'
Private content (the right way)¶
Use the default router and pass sensitive: true:
curl -sS "$SMART_GATEWAY_BASE_URL/v1/chat/completions" \
-H "Authorization: Bearer $SMART_GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "smart-router",
"messages": [{"role": "user", "content": "<paste internal code here>"}],
"metadata": {"sensitive": true}
}'
The default is sensitive: true; setting it explicitly is a good
defensive habit.
Multipart / multimodal (rejected)¶
# This returns HTTP 400.
curl -sS "$SMART_GATEWAY_BASE_URL/v1/chat/completions" \
-H "Authorization: Bearer $SMART_GATEWAY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "smart-router",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{"type": "image_url", "image_url": {"url": "https://example.com/x.png"}}
]
}]
}'
v1.0.0 does not support multimodal. See Getting started → Concepts.