POST /v1/chat
Route a chat completion request to the best model for your task.
Request headers
| Header | Required | Description |
|---|---|---|
| Authorization | Yes | Bearer YOUR_API_KEY |
| Content-Type | Yes | application/json |
| x-pathfinder-filters | No | Comma-separated routing filters (see Routing) |
| Idempotency-Key | No | Dedup key for non-streaming requests (see API Key Config) |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
| messages | array | Yes | Array of message objects with role and content |
| stream | boolean | No | Enable SSE streaming (default: false). See Streaming |
| max_tokens | number | No | Maximum tokens to generate. May be capped by per-key config |
| temperature | number | No | Sampling temperature (0–2) |
Example
curl https://api.pathfinder.dev/v1/chat \
-H "Authorization: Bearer pf_live_xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Solve x^2 - 5x + 6 = 0" }
],
"max_tokens": 1024
}'Response body
Standard Chat Completions response from the selected provider, returned as-is.
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"choices": [{
"index": 0,
"message": { "role": "assistant", "content": "..." },
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 42,
"completion_tokens": 128,
"total_tokens": 170
}
}Response headers
Every response includes routing metadata. These are exposed via CORS so browser clients can read them.
| Header | Example | Description |
|---|---|---|
| X-Routed-Model | claude-sonnet-4 | Model that handled the request |
| X-Task-Type | coding | Detected task type |
| X-Provider | anthropic | Provider that served the request |
| X-Routing-Fee | 0.0004 | Routing fee in USD |
| X-Classification-Confidence | 0.95 | Task classifier confidence (0–1) |
| X-Data-Confidence | 0.82 | Benchmark data coverage (0–1) |
| X-Benchmark-Score | 87.3 | Model's score for this task (0–100) |