SDKs
REST API
Direct HTTP requests for any language.
REST API
Use direct HTTP requests to interact with AssistantRouter from any programming language.
Base URL
https://api.assistantrouter.com/v1Authentication
Include your API key in the Authorization header:
Authorization: Bearer ar_live_xxxxxxxxChat Completions
curl https://api.assistantrouter.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ASSISTANTROUTER_API_KEY" \
-d '{
"model": "anthropic/claude-haiku-4.5",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
}'package main
import (
"bytes"
"encoding/json"
"net/http"
"os"
)
func main() {
payload := map[string]interface{}{
"model": "anthropic/claude-haiku-4.5",
"messages": []map[string]string{
{"role": "user", "content": "Hello!"},
},
}
body, _ := json.Marshal(payload)
req, _ := http.NewRequest(
"POST",
"https://api.assistantrouter.com/v1/chat/completions",
bytes.NewBuffer(body),
)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+os.Getenv("ASSISTANTROUTER_API_KEY"))
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
}require 'net/http'
require 'json'
uri = URI('https://api.assistantrouter.com/v1/chat/completions')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request['Authorization'] = "Bearer #{ENV['ASSISTANTROUTER_API_KEY']}"
request.body = {
model: 'anthropic/claude-haiku-4.5',
messages: [{ role: 'user', content: 'Hello!' }]
}.to_json
response = http.request(request)
puts JSON.parse(response.body)<?php
$ch = curl_init('https://api.assistantrouter.com/v1/chat/completions');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Authorization: Bearer ' . getenv('ASSISTANTROUTER_API_KEY'),
],
CURLOPT_POSTFIELDS => json_encode([
'model' => 'anthropic/claude-haiku-4.5',
'messages' => [
['role' => 'user', 'content' => 'Hello!']
]
]),
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
echo $data['choices'][0]['message']['content'];Streaming (Server-Sent Events)
For streaming responses, set stream: true and handle SSE:
curl https://api.assistantrouter.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ASSISTANTROUTER_API_KEY" \
-d '{
"model": "anthropic/claude-haiku-4.5",
"messages": [{"role": "user", "content": "Tell me a story"}],
"stream": true
}'Response format:
data: {"id":"chatcmpl-xxx","choices":[{"delta":{"content":"Once"}}]}
data: {"id":"chatcmpl-xxx","choices":[{"delta":{"content":" upon"}}]}
data: {"id":"chatcmpl-xxx","choices":[{"delta":{"content":" a"}}]}
data: [DONE]Request Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer token with your API key |
Content-Type | Yes | Must be application/json |
X-Assistant-Id | No | Use a specific assistant |
X-Request-Id | No | Custom request ID for tracking |
Response Format
Success
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1704067200,
"model": "anthropic/claude-haiku-4.5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 8,
"total_tokens": 18
}
}Error
{
"error": {
"message": "Invalid API key provided",
"type": "authentication_error",
"code": "invalid_api_key"
}
}OpenAPI Specification
Download the full OpenAPI spec:
curl https://api.assistantrouter.com/docs/openapi.json -o openapi.jsonUse the OpenAPI spec with tools like Postman, Insomnia, or code generators.