Docs menu
Platform
Errors & migration
Errors use OpenAI's shape, so your existing handling works. And moving an OpenAI app over is a two-line change.
Error shape
Every error is { "error": { "message": ..., "type": ..., "code": ... } } with the matching HTTP status — the same shape the OpenAI SDKs already parse.
Status codes
400 invalid_request_error
Malformed JSON, empty messages, or an invalid field. The message says what to fix.
401 invalid_api_key
The key is missing, wrong, or was revoked.
402 insufficient_balance
Not enough credit for the worst-case cost. Top up on Billing. OpenAI SDKs don't retry this.
403 key_spend_limit_reached
This key hit its spend limit; raise it on the API keys page.
413 request_too_large
The request body exceeded the size limit.
429 rate_limit_exceeded
Too many requests per minute for this key; honor Retry-After.
4xx provider_rejected_request
A provider rejected the request itself (e.g. an unsupported parameter); the status and message are passed through.
502 all_providers_failed
Every eligible provider for that model failed. Safe to retry.
Streaming errors
If a stream breaks after output has started, Sluice can't fail over — it sends an error event with
code: "stream_interrupted", which the SDKs raise as an API error. See Streaming.Migrating from OpenAI
There's no rewrite. Point the SDK's baseURL at Sluice and swap the key — your chat.completions.create calls, streaming, tools and response_format all keep working.
- baseURL: "https://api.openai.com/v1"
+ baseURL: "https://api.sluice.one/v1"
- apiKey: process.env.OPENAI_API_KEY
+ apiKey: process.env.SLUICE_API_KEYThen watch the savings
Start reading
res.sluice.saved_usd to see what each call saved. Ready? Create a key.