SwarmSync exposes an OpenAI-compatible API that automatically routes every request to the best available model based on task complexity, capability matching, and tier constraints.
The routing layer is a drop-in replacement for the OpenAI API. Set baseURL to the SwarmSync endpoint and authenticate with your sk-ss-... key.
import OpenAI from 'openai';
const client = new OpenAI({
baseURL: 'https://api.swarmsync.ai/v1',
apiKey: process.env.SWARMSYNC_ROUTING_KEY, // sk-ss-...
});
const response = await client.chat.completions.create({
model: 'auto', // auto-routes to best model
// model: 'economy', // → economy tier (same as swarmsync/budget)
// model: 'premium', // → premium tier (same as swarmsync/performance)
messages: [{ role: 'user', content: 'Your prompt here' }],
});
// Every response includes routing metadata
const meta = response.swarmsync;
console.log(meta.routed_model); // e.g. "claude-sonnet-4-6"
console.log(meta.tier); // "economy" | "mid" | "premium"
console.log(meta.complexity_score); // 0.0 – 1.0
console.log(meta.estimated_cost); // USD including 8% platform feeAll routing endpoints require a routing API key passed in the Authorization header.
Manage your keys at /console/settings/routing-keys. Keys are scoped per user account and track usage independently.
Base URL: https://api.swarmsync.ai
OpenAI-compatible chat completions with auto-routing. Pass model: "auto" for intelligent routing or any virtual alias.
List all available models with tier, pricing, capability scores, and provider information.
Preview which model would be selected for a given prompt. Performs scoring only — no LLM call is made.
List routing API keys for your account. Authenticated with your sk-ss- routing key. The legacy path /v1/auth/keys also works but requires a JWT.
Usage stats and cost summary for the authenticated API key.
The POST /v1/route endpoint accepts the same body as POST /v1/chat/completions but performs only scoring and model selection — no LLM call is made and no tokens are consumed.
// Dry-run: see which model would be chosen without spending tokens
const res = await fetch('https://api.swarmsync.ai/v1/route', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer sk-ss-...',
},
body: JSON.stringify({
model: 'auto',
messages: [{ role: 'user', content: 'Refactor this TypeScript class...' }],
}),
});
const { model, tier, complexity_score } = await res.json();Pass one of these strings as the model field instead of a specific model ID to use the routing system. You can also pin a specific model (e.g. "claude-sonnet-4-6") to bypass routing entirely.
"auto"Full two-stage routing: complexity score determines tier, then capability matching picks the best model within that tier. Recommended default.
"economy"Forces routing to the economy tier (score 0.0-0.3). Ideal for high-volume tasks: summaries, extraction, simple Q&A. Short alias for swarmsync/budget.
"budget"Forces routing to the economy tier. Equivalent to economy.
"swarmsync/budget"Canonical economy-tier alias. Equivalent to economy and budget.
"premium"Forces routing to the premium tier (score 0.7-1.0). Selects frontier models for complex reasoning, agentic workflows, and long-context tasks. Short alias for swarmsync/performance.
"performance"Forces routing to the premium tier. Equivalent to premium.
"swarmsync/performance"Canonical premium-tier alias. Equivalent to premium and performance.
"balanced"Forces routing to the mid tier (score 0.3-0.7). Short alias for swarmsync/balanced.
"swarmsync/balanced"Canonical mid-tier alias. Complexity-based routing that caps selection to the mid tier. Equivalent to balanced.
Every response from /v1/chat/completions includes a swarmsync object alongside the standard OpenAI fields. Use this to audit routing decisions, track cost savings, and tune your model strategy.
| Field | Type | Description |
|---|---|---|
| routed_model | string | The canonical model ID that was selected and called (e.g. "claude-sonnet-4-6"). |
| routing_reason | string | Human-readable explanation of why this model was chosen, including tier, dominant signals, and top task dimension (e.g. "mid_complexity_code_presence+reasoning_keywords_task:coding"). |
| complexity_score | number | Raw complexity score from 0.0 to 1.0. Below 0.3 = economy, 0.3–0.7 = mid, above 0.7 = premium. |
| estimated_cost | number | Estimated USD cost of this request based on token counts and the selected model's pricing, inclusive of the 8% platform fee. |
| tier | string | The routing tier used: "economy", "mid", or "premium". |
| savings_vs_premium | number | Estimated USD saved compared to routing the same request to the most expensive available model. |
All standard OpenAI chat completion parameters are supported and forwarded to the selected provider. The routing layer adds the model alias resolution on top.
| Parameter | Required | Description |
|---|---|---|
| model | required | Any virtual alias (auto, economy, budget, balanced, premium, swarmsync/budget, swarmsync/balanced, swarmsync/performance) or a pinned model ID. |
| messages | required | OpenAI-format message array: [{ role: "user" | "assistant" | "system", content: string }]. |
| temperature | optional | Float in range 0.0–2.0. Values exactly at 0 are normalized to 0.0001 for provider compatibility. Defaults to the model's own default if omitted. |
| max_tokens | optional | Maximum tokens in the completion. Forwarded as-is to the provider. |
| top_p | optional | Nucleus sampling probability. Forwarded to providers that support it. |
| stream | optional | Boolean. When true, returns a server-sent events stream (text/event-stream). Defaults to false. |
| tools | optional | OpenAI-format tools array for function calling. The router automatically selects a tool-capable model when this field is present. |
| response_format | optional | OpenAI-format response_format object (e.g. { type: "json_object" }). Triggers structured-output routing. |
| stop | optional | Stop sequence string or array. Forwarded to the provider. |
Get a routing key from your console and start calling 15 frontier models through a single OpenAI-compatible endpoint.