API reference
Authentication
Every request carries your key as a bearer token. Keys are per project and can be revoked at any moment.
Authorization: Bearer $SWITCHLLM_KEY Content-Type: application/json
Never ship a key inside client-side code. If one leaks, revoke it in the console and create a new one.
Endpoints
Base URL: https://switchllm.net/v1
| Method | Path | Purpose |
|---|---|---|
| POST | /v1/chat/completions | Chat completions. Works with the OpenAI SDKs and most desktop clients. |
| POST | /v1/responses | Responses API format, for clients built on that shape. |
| POST | /v1/messages | Messages format, for clients that speak it. |
| GET | /v1/models | List the models your key can reach. |
Which endpoints answer depends on the model source behind each model. GET /v1/models and the console are always the source of truth.
Errors
| Code | Meaning | What to do |
|---|---|---|
| 401 | Missing, wrong or revoked key | Check the Authorization header, or create a new key in the console. |
| 402 | Balance or monthly cap used up | Top up, or raise the cap on that key. |
| 404 | Unknown model id | Copy the exact id from the console or from GET /v1/models. |
| 429 | Rate or concurrency limit hit | Back off and retry. Concurrency depends on your plan. |
| 5xx | A model source failed | Retry. Traffic is moved to another source automatically. |
Limits
- Each key has its own monthly cap; when it is reached, requests stop instead of overspending.
- Concurrency depends on your plan. Streaming is supported on every chat endpoint.
- Usage and balance are in the console, per key and per day.