

Support
Complete developer reference for the AI Smart Router. Requests go to https://aistupidlevel.info/v1 with your aism_ key as a Bearer token.
https://aistupidlevel.info/ v1Bearer aism_keyThe AI Smart Router provides an OpenAI-compatible API that intelligently routes your requests to the best AI model for the job, based on benchmarks that re-run on a fixed schedule (coding every four hours, reasoning and tool use daily). Use a single aism_ key — your SR (Smart Router) key — to access models from 6 providers: OpenAI, Anthropic, Google (Gemini), DeepSeek, Kimi (Moonshot), and GLM (Z.AI).
https://aistupidlevel.info/ v1All requests require a Bearer token in the Authorization header:
Authorization: Bearer aism_your_api_key_hereSome tools enforce an sk- prefix for API keys. The router accepts sk-aism_... — the prefix is stripped automatically.
Project keys. A key made on a workspace project’s page works the same way, but follows the project’s routing rules (strategy, allowed models, limits), pays with the project’s or workspace’s provider keys, and counts against the project’s budget and the holder’s cap in it — see the workspace guide. Keys can also expire; an expired key gets a 401 saying when it expired.
| Method | Path | Description |
|---|---|---|
| POST | /v1/chat/completions | Chat completions (auto-routing or direct pin) |
| GET | /v1/models | List available models (requires auth) |
| POST | /v1/embeddings | Embeddings (proxied to OpenAI) |
| POST | /v1/messages | Native Anthropic Messages API passthrough (Claude Code) |
| POST | /v1/messages/count_tokens | Anthropic token counter (free; not counted against your plan) |
| POST | /v1/router/feedback | Rate an answer up or down by its completion id |
| POST | /v1/route/preview | The model, fallbacks and reasons a chat request would get, without sending it |
| GET | /v1/usage | This month's requests, prepaid credits and the key's budget |
| GET | /v1/openapi.json | OpenAPI 3.1 description of the router API (no key needed) |
| POST | /v1/explain | Which model “auto” would pick for a prompt, without sending it |
| POST | /v1/compare | What every strategy would pick for a prompt |
| POST | /v1/analyze | How the router classifies a prompt |
Official clients for TypeScript and Python, and a provider for the Vercel AI SDK. Any OpenAI client works too (see Integrations); the SDKs add what an OpenAI client cannot see.
@aistupidlevel/routerfetchaistupidlevel@aistupidlevel/ai-sdk-providergenerateText, streamText, tools)// npm install @aistupidlevel/router import { ASLRouter } from '@aistupidlevel/router'; const router = new ASLRouter(); // reads ASL_ROUTER_KEY const r = await router.chat.completions.create({ model: 'auto-coding', messages: [{ role: 'user', content: 'Fix the off-by-one in this loop: ...' }], }); console.log(r.choices[0].message.content); console.log(r.routing.model, r.routing.reasoning); // which model answered, and why // Streaming const stream = await router.chat.completions.create({ model: 'auto-best', messages, stream: true }); for await (const text of stream.textStream()) process.stdout.write(text);
Routing on every answer. routing carries the provider and model that answered, why they were chosen, the latency, the request id, and whether a fallback answered (routing.fallback). For a stream it is known before any chunk arrives.
Safe retries. Connection failures, timeouts, 408, 409, 429 and 5xx are retried twice by default with backoff, honouring Retry-After. Every non-streaming request carries an Idempotency-Key, so a retry of a request whose answer was lost is never charged twice. Errors that retrying cannot fix (allowance used up, a budget reached, a provider key refused) are not retried.
Errors that say whose problem it is. Each error class has a party (request, account, provider_key, provider, router or network) and a retryable flag, so an app can tell its user to top up, to fix a provider key, or simply to try again.
Tool loops. chat.runTools (Python: chat.run_tools) runs a tool-calling conversation to its final answer: it calls your handlers, sends their results back, and reports a handler's exception to the model instead of crashing. The loop stays on one model throughout.
const { completion, rounds } = await router.chat.runTools( { model: 'auto-tooling', messages, tools }, { handlers: { get_weather: async ({ city }) => ({ city, temp: 7 }) } }, );
The API is also described in OpenAPI 3.1 at /v1/openapi.json, for generating a client in any other language. Source: github.com/StudioPlatforms/aistupidlevel-sdk.
/v1/chat/completionsCreate a chat completion. Use an auto-* virtual model for intelligent routing, or a real model ID for direct pin routing.
{
"model": "auto-coding",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Write a Python fibonacci function"}
],
"temperature": 0.7,
"max_tokens": 1000,
"stream": false
}| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | "auto-coding", "auto-reasoning", or any real model ID that GET /v1/models lists |
messages | array | Yes | Array of {role, content} message objects |
temperature | number | No | Sampling temperature (0-2). Default varies by provider. |
max_tokens | number | No | Max tokens to generate. For reasoning models use max_completion_tokens. |
max_completion_tokens | number | No | Max output tokens including reasoning tokens (OpenAI reasoning models). |
stream | boolean | No | Enable SSE streaming. Default: false. |
stream_options | object | No | { include_usage: true } — emit final usage chunk in SSE. |
tools | array | No | Function tool definitions for tool calling. |
tool_choice | string|object | No | "auto", "none", "required", or {type:"function", function:{name}}. |
response_format | object | No | { type: "json_object" } or { type: "json_schema", json_schema: {...} }. |
reasoning_effort | string | No | "none"|"minimal"|"low"|"medium"|"high"|"xhigh"|"max". Any value works with any model: the router maps it to the nearest level the chosen model supports (a tie goes to the deeper level). |
top_p | number | No | Nucleus sampling. Default: 1. |
frequency_penalty | number | No | Frequency penalty (-2 to 2). Not supported by all providers. |
presence_penalty | number | No | Presence penalty (-2 to 2). Not supported by all providers. |
stop | string|array | No | Stop sequences. Not supported by all providers. |
seed | number | No | Random seed for reproducibility. |
from openai import OpenAI client = OpenAI( api_key="aism_your_key_here", base_url="https://aistupidlevel.info/v1" ) response = client.chat.completions.create( model="auto-coding", messages=[{"role": "user", "content": "Hello!"}] ) print(response.choices[0].message.content)
{
"id": "chatcmpl-1748250000000",
"object": "chat.completion",
"created": 1748250000,
"model": "<the model that answered>",
"system_fingerprint": "aism_v1_<provider>",
"service_tier": "default",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?",
"refusal": null,
"annotations": []
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 9,
"total_tokens": 21,
"prompt_tokens_details": { "cached_tokens": 0 },
"completion_tokens_details": { "reasoning_tokens": 0 }
}
}X-AISM-ProviderX-AISM-ModelX-AISM-ReasoningX-AISM-LatencyX-AISM-Request-IdX-AISM-Streaming-Modenative when streamed text arrives as the model writes it; buffered for a streamed forced tool call, which is checked before anything is sent — see Tools, JSON and streamingUse these as the model parameter for intelligent routing.
| Model ID | Strategy | Description |
|---|---|---|
auto | Default | Uses your saved routing strategy from Preferences |
auto-task | Per request | Reads each request and picks the matching benchmark: tools → tool use, design or long sessions → reasoning, code → coding, else overall; simple requests use the Best value version. The routing reason names the rule |
auto-split | Your split | Your own weighted traffic split across models you choose (set it in Preferences); the rest of the split goes ahead of your fallback order |
auto-coding | Coding | Best for code generation, debugging, refactoring |
auto-reasoning | Reasoning | Best for complex analysis, math, logic |
auto-consistent | Consistency | Among models within 5 points of the best one you can use, the one whose score swings least from run to run |
auto-fastest-quality | Speed | Among models within 5 points of the best one you can use, the fastest (measured latency) — auto-fastest has no quality bar |
auto-creative | Legacy | Still accepted and routed as auto-best — there is no creative-writing benchmark |
auto-cheapest | Cost | Lowest list price per token among your providers — no quality bar |
auto-value | Value | Most combined-score points per measured dollar, among models within 5 points of the best one you can use |
auto-value-coding | Value | Most coding points per dollar (measured cost of a coding run), near-top models only |
auto-value-reasoning | Value | Most reasoning points per dollar (measured cost of a reasoning run), near-top models only |
auto-value-tooling | Value | Most tool-use points per dollar (measured cost of a tool-use run), near-top models only |
auto-value-agentic | Value | Alias for auto-value-tooling |
auto-fastest | Speed | Lowest latency response time |
auto-tooling | Tool use | Best at calling tools correctly — scored on our tool-calling suite |
auto-agentic | Tool use | Alias for auto-tooling; "agentic" is what most tools call it |
auto-best | Overall | Best combined score regardless of category; among statistically tied leaders, your tie-break decides (the cheaper by default) |
Direct pin routing: Send any real model ID (GET /v1/models lists them all) to bypass the strategy router and forward directly to that provider.
How the best model is chosen: every model ranks on the average of its last five scored benchmark runs, never on a single run. When the leaders are closer than the test can tell apart (within 1.96 times their combined standard error, the same test as the leaderboard's = ranks), they are tied, and your tie-break in Preferences picks among them: the one that cost least per task in our runs (the default), the fastest, or the highest score. A model you were already routed to stays while it is still tied, and a conversation stays on the model that answered it, so the pick does not change with every new run. Unknown auto-* names are a 400 model_not_found that lists the valid ones.
Near-top strategies (auto-value*, auto-consistent, auto-fastest-quality) only choose among models within 5 points of the best model you can use — after your keys, exclusions and limits — so a cheaper, steadier or faster pick is never a much weaker one. Value is per run: the benchmark score divided by what one identical benchmark run cost that model, not its list price per token.
Drift-aware routing (on by default, see Preferences): a model whose drift detector has fired for the skill your strategy relies on, or whose hourly canary is failing, is moved behind every unflagged model. It is never removed — if every candidate is flagged, the best of them is still used — and the routing reason names any model that was passed over and why.
/v1/modelsList available models. Returns virtual auto-* models plus all real models that have been benchmarked. Requires authentication.
curl https://aistupidlevel.info/v1/models \ -H "Authorization: Bearer aism_your_key_here"
Tools like Roo Code, Continue, Open WebUI, and LibreChat call this endpoint to populate their model dropdowns.
Tool calling works end to end. Send OpenAI-format tools; the response carries tool_calls with the provider's own ids. Send the results back as role: "tool" messages with tool_call_id, exactly as with OpenAI. The router remembers each model's own turn for 24 hours (Claude's thinking blocks, OpenAI reasoning items, Gemini thought signatures), so multi-step agent loops keep working, and a conversation stays on the model that started it.
Prompt caching is on. Agent loops resend the whole conversation every turn, and every provider can serve the part it has seen from its prompt cache at a fraction of the input price. OpenAI, Gemini, DeepSeek, Kimi and GLM do it automatically; for Claude, which caches only when asked, the router asks for every conversation that continues (one with tools, or with an answer in it already). Cached tokens are reported in usage.prompt_tokens_details.cached_tokens and costed at the cache rate in Monitoring and budgets.
Refusals: when a model declines a request, the answer comes back with message.refusal and finish_reason: "content_filter", and it is not counted against your allowance. The Claude models that support it first retry on Anthropic's own fallback model in the same call. A refused request is not sent to other providers.
tool_choice: auto and none work everywhere, and required or a named function works on every model. OpenAI, Gemini and most DeepSeek, Kimi and Claude models enforce it natively (DeepSeek switches thinking off for that one request), and routed requests that force a tool go to those first. Models whose APIs cannot be forced (GLM, and some Kimi and Claude models; GLM even accepts the setting and ignores it) get an instruction for that turn instead: the router checks that the answer really is the tool call, retries once, and otherwise falls back or answers 502 tool_choice_not_honoured. It never hands you prose when you forced a tool. Streamed forced calls arrive in one piece (X-AISM-Streaming-Mode: buffered), because the answer is checked before anything is sent.
JSON output: response_format json_object and json_schema are supported for every provider. The schema is enforced natively by OpenAI, Gemini and the Claude models that support structured output (when every object sets additionalProperties: false); DeepSeek, Kimi and GLM receive the schema as an instruction in JSON mode.
Streaming (stream: true) is real: text arrives as the model writes it (X-AISM-Streaming-Mode: native). Tool calls arrive in one chunk each once the model has finished them, then the finish reason, then usage if you set stream_options.include_usage. If the chosen model fails before sending anything, or its provider sends nothing at all for 120 seconds, the next fallback is tried; once bytes have been sent, a failure ends the stream with an error event.
Text only, by design. The router picks a model from our benchmark results for coding, reasoning and tool use; none of those measure image, audio or file understanding, so a request with them gets a 400 unsupported_content rather than a routing decision we cannot back. n must be 1. Requests can be up to 32 MB — about a million tokens of code in context.
Ratings help routing learn from real use:
curl -X POST https://aistupidlevel.info/v1/router/feedback \ -H "Content-Type: application/json" \ -H "Authorization: Bearer aism_your_key_here" \ -d '{"id": "chatcmpl-...", "rating": "up"}'
Use the id from the completion (also in X-AISM-Request-Id); rating is "up"/1 or "down"/-1. Ratings nudge rankings only slightly, and only once enough have accumulated.
Build and test against the router without provider keys, without spending anything, and without using your allowance.
Send X-ASL-Sandbox: true and the request goes through the real pipeline (authentication, validation, your preferences, the live ranking and fallback chain) but no provider is called. The answer is a deterministic mock in exactly the shape of a real one: the same headers, streaming chunks, tool calls with arguments that fit your schema, JSON that fits your response_format, and usage. It carries X-AISM-Sandbox: true, needs no provider key (routing runs as if you had one for every provider), and counts against no allowance or budget.
curl https://aistupidlevel.info/v1/chat/completions \ -H "Authorization: Bearer aism_your_key_here" \ -H "Content-Type: application/json" \ -H "X-ASL-Sandbox: true" \ -d '{"model": "auto-coding", "messages": [{"role": "user", "content": "Hello!"}]}'
X-ASL-Sandbox-Simulate makes a sandbox request fail the way a real one can, so your error handling can be tested: rate_limited, allowance_exhausted, insufficient_quota, provider_key_rejected, model_unavailable, server_error, or fallback (the primary fails and the next model answers, as shown in X-AISM-Reasoning).
/v1/route/previewTakes the same body as a chat request and returns the routing decision it would get (strategy, model, fallbacks, scores and the reasons) without sending it. Nothing is called or counted. With your real keys it shows what your request will do; with X-ASL-Sandbox: true it shows what a sandbox request would route to.
curl https://aistupidlevel.info/v1/route/preview \ -H "Authorization: Bearer aism_your_key_here" \ -H "Content-Type: application/json" \ -d '{"model": "auto-coding", "messages": [{"role": "user", "content": "Fix this bug"}]}'
{
"object": "route.preview",
"requested_model": "auto-coding",
"strategy": "best_coding",
"sandbox": false,
"primary": {
"model": "<model id>",
"provider": "<provider>",
"score": 99,
"reasoning": "Selected <model id> from <provider> for best coding performance ...",
"estimated_cost_usd": 0.012
},
"fallbacks": [
{ "model": "<model id>", "provider": "<another provider>", "score": 96, "reasoning": "Fallback: ...", "estimated_cost_usd": 0.012 }
],
"fallback_enabled": true
}/v1/usageThis month's requests used and included in your plan, your prepaid credits, whether a request would be accepted now, and this key's monthly budget and spend. Free, and not counted.
curl https://aistupidlevel.info/v1/usage \ -H "Authorization: Bearer aism_your_key_here"
Send Idempotency-Key (any unique string up to 255 characters) on POST /v1/chat/completions and you can safely retry a request whose response you never received. For 24 hours, the same key from the same account returns the stored response instead of routing again, marked Idempotent-Replayed: true, and is not counted again. The SDKs send one on every non-streaming request.
curl https://aistupidlevel.info/v1/chat/completions \ -H "Authorization: Bearer aism_your_key_here" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: order-4821-summary" \ -d '{"model": "auto", "messages": [{"role": "user", "content": "Summarise order 4821"}]}'
Only final answers are kept. A 5xx or a 429 is not stored, so retrying after a failure or a rate limit is a real new attempt. Reusing a key with a different body gets 422 idempotency_key_reused; a retry that arrives while the original attempt is still running gets 409 idempotency_in_progress with Retry-After. Streams cannot be replayed, so streaming requests ignore the header.
x-should-retry. Error responses that retrying cannot fix (allowance_exhausted, insufficient_quota, provider_quota_exceeded) carry x-should-retry: false, which the official OpenAI SDKs and ours obey, so a client does not retry them in a loop.
/v1/embeddingsGenerate embeddings via OpenAI's embedding models. Required by Continue, LibreChat, Open WebUI, and AnythingLLM for RAG features.
curl -X POST https://aistupidlevel.info/v1/embeddings \ -H "Content-Type: application/json" \ -H "Authorization: Bearer aism_your_key_here" \ -d '{"model": "text-embedding-3-small", "input": "Hello world"}'
Requires an active OpenAI provider key. Supported models: text-embedding-3-small (also auto-embedding), text-embedding-3-large. Each call counts as one request against your plan, and per-key budgets apply.
/v1/messagesAnthropicNative Anthropic Messages API passthrough. Unlocks Claude Code, Cline's Anthropic provider, Roo Code's Anthropic provider, and TypingMind's Anthropic preset.
Accepts aism_ keys via either x-api-key or Authorization: Bearer header. Forwards the anthropic-version header (defaults to 2023-06-01) and any anthropic-beta header as sent. POST /v1/messages/count_tokens is passed through too; it is free at Anthropic, so it is not counted against your plan.
export ANTHROPIC_BASE_URL="https://aistupidlevel.info" export ANTHROPIC_API_KEY="aism_your_key_here" claude
There is no routing on this path: the request goes to Anthropic, with your Anthropic key, for the Claude model it names. Your plan allowance, budgets and request logs apply as on the other endpoints.
curl -X POST https://aistupidlevel.info/v1/messages \ -H "Content-Type: application/json" \ -H "x-api-key: aism_your_key_here" \ -H "anthropic-version: 2023-06-01" \ -d '{ "model": "<a Claude model id>", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello!"}] }'
Requires an active Anthropic provider key. Returns native Anthropic response format (not OpenAI-translated).
| HTTP code | error.type | error.code | Description |
|---|---|---|---|
| 400 | invalid_request_error | invalid_messages/ invalid_tools/ unsupported_content/ model_not_found | The request cannot be routed as sent (the message says what to change) |
| 400 | invalid_request_error | provider_rejected_request | The provider rejected the request itself; its own words are in the message |
| 400 | invalid_request_error | provider_key_rejected/ no_provider_keys | Your provider key is missing or was refused — add or update it in Providers |
| 400 | invalid_request_error | no_routable_model | Your preferences exclude every model (the message names the setting) |
| 401 | authentication_error | invalid_api_key | Missing or invalid aism_ key |
| 401 | authentication_error | expired_api_key | The key had an expiry date and it has passed (the message says when) |
| 400 | invalid_request_error | pinning_not_allowed/ model_not_allowed/ provider_not_allowed | Project keys: the project routes every request, or does not allow that model or provider |
| 403 | permission_error | not_in_workspace/ not_in_project/ seat_required/ project_deleted/ plan_lapsed | Project keys: the holder left, lost their seat, or the project or its plan is gone |
| 429 | rate_limit_error | rate_limited | Project keys: the project’s requests-per-minute limit for this key (see Retry-After) |
| 429 | rate_limit_error | project_budget_exceeded | Project keys: the request could take the project past its monthly budget |
| 429 | rate_limit_error | member_cap_reached | Project keys: you reached your monthly cap in the project |
| 429 | rate_limit_error | budget_downgraded | Project keys: the budget is spent and the project now routes only (cheapest models); naming a model is refused |
| 429 | rate_limit_error | allowance_exhausted | This month's requests are used up and you have no prepaid credits |
| 429 | rate_limit_error | insufficient_quota | This key's monthly hard budget would be exceeded |
| 429 | rate_limit_error | provider_quota_exceeded | Your provider account refused for credit or quota |
| 429 | rate_limit_error | provider_rate_limited | Your provider key is being rate-limited on every model tried (see Retry-After). Other models and providers are tried first |
| 400 | invalid_request_error | invalid_idempotency_key | Idempotency-Key must be 1–255 printable ASCII characters |
| 422 | invalid_request_error | idempotency_key_reused | The Idempotency-Key was already used with a different request body |
| 409 | conflict_error | idempotency_in_progress | A request with this Idempotency-Key is still running (see Retry-After) |
| 413 | none | none | The request body is over 32 MB; the response is a plain message with no error object |
| 502 | api_error | model_unavailable | Every model tried failed on the provider side |
| 502 | api_error | tool_choice_not_honoured | You forced a tool call and the model answered without one, twice (only models that cannot be forced natively; see Tools above) |
| 500 | server_error | internal_error | Internal server error |
{
"error": {
"message": "Invalid API key. Generate a new key at https://aistupidlevel.info/router/keys",
"type": "authentication_error",
"code": "invalid_api_key"
}
}SDKs use error.type and error.code for retry decisions. These match the OpenAI standard.
The router is an OpenAI-compatible endpoint, so any tool that lets you set a base URL works with it. Below are the ready-made integrations, then the settings for the tools people use most.
n8n-nodes-aistupidlevel@aistupidlevel/mcplangchain-aistupidlevelChatAISL: tools, structured output and streaming, plus the model that answered and why@aistupidlevel/ai-sdk-providergenerateText, streamText and tools@aistupidlevel/dsh-provider@aistupidlevel/openclaw-provideraistupidlevelhermes plugins install aistupidlevel@aistupidlevel/pi-providerpi install npm:@aistupidlevel/pi-providerlfx-aistupidlevelpip install lfx-aistupidlevel, then restart LangflowUse your router key (aism_…) wherever a tool asks for an API key, and a routing mode such as auto-coding as the model (see Virtual models). The MCP server and the n8n benchmark operations also take a Data API key (asl_live_…), from Data API keys.
If you use CC Switch, one click adds AI Stupid Level to one of these apps with auto-coding as the model, and CC Switch asks for your router key. A key you create on the Keys page comes with the same buttons, with the key already filled in.
Install:
n8n Cloud search "AI Stupid Level" on the canvas (a verified node;
Verified Community Nodes must be on in the Admin Panel)
Self-hosted Settings → Community Nodes → Install → n8n-nodes-aistupidlevel
Credentials:
AI Stupid Level Router API router key (aism_…) chat and routing
AI Stupid Level Data API Data API key (asl_live_…) rankings, drift, incidents
Nodes:
AI Stupid Level Chat · Router (preview, usage) · Benchmark data
AI Stupid Level Chat Model plug into an AI Agent or LLM chain; every call,
tool turns included, goes through the routerfrom openai import OpenAI client = OpenAI(api_key="aism_your_key_here", base_url="https://aistupidlevel.info/v1") raw = client.chat.completions.with_raw_response.create( model="auto-coding", messages=[{"role": "user", "content": "Hello!"}] ) print(raw.headers["x-aism-model"]) # the model that answered print(raw.parse().choices[0].message.content)
Questions? Check the Help center