Chabi

Developer Reference

Reference

Credits, errors, limits and every endpoint.

Updated November 2026

Credits

Users pay Chabi a monthly plan with included credits; you pay nothing. Each model's price in credits is in MODEL NOTES: pricier models use more.

  • Before a request runs, Chabi holds the most it could cost: the input plus the full output cap (4,096 tokens if you don't set one). Afterwards it charges the actual usage and releases the rest. A tight output cap lets users with few credits keep going.
  • Each web search costs 1.5 credits, plus the tokens its results add to the input. Each search step reads the prompt again, so the hold includes, for every search the request allows (max_uses or max_tool_calls), the fee, the prompt and room for results. A lower cap lets users with few credits search too.
  • Inline files are held by what they hold, not their size: 5,000 input tokens per PDF page and 6,000 per image. The provider's reported usage is what's charged, which is usually much less.
  • If the hold doesn't fit the user's balance, the request is refused with 402 before anything is sent to the provider. So a user can get 402 with credits left: required_credits is the hold, not the final charge.
  • The same feature costs a different amount each time, depending on how long the input and reply are. Don't promise a fixed price per action in your UI.
  • You earn 0.6¢ for every paid credit your users spend in your app, plus a share of their unused plan credits, paid monthly once you're owed $10. Track it under Earnings in the developer portal; how it's worked out and paid is in the terms.

Errors

Errors come back in each SDK's own shape, so err.status works as usual. The Anthropic SDK nests the details one level deeper (err.error.error).

StatusCodeWhat to do
400invalid_body model_not_supported unsupported_parameter unsupported_audio_format voice_not_supported input_too_long upstream_rejectedThe request is wrong: fix it, don't retry. unsupported_audio_format means the audio wasn't uncompressed WAV. upstream_rejected carries the provider's own message.
401missing_token invalid_token token_revoked grant_revoked unknown_appSend the user through sign-in again. grant_revoked means they removed your app's access.
402insufficient_credits app_limit_reachedinsufficient_credits: the user is out of credits. The body has balance_credits, required_credits and upgrade_url: send them there. app_limit_reached: the user set a monthly limit on what your app can spend and this request could go over it. The body has limit_credits, spent_credits, required_credits and manage_url, where they can raise it.
403app_suspendedYour app was suspended. Email hello@chabi.dev.
413body_too_largeText is limited to 1 MB, a request with inline files and images to 20 MB, audio uploads to 25 MB. Send shorter chunks.
429user_rate_limited app_rate_limitedToo many requests. Wait for the Retry-After header's seconds.
502, 503provider_error provider_overloaded provider_not_configured format_unavailableThe AI provider failed or is busy. Retry with backoff. format_unavailable (text to speech): ask for wav or pcm instead.
try {  // ...the request} catch (err) {  const info = err.error?.error ?? err.error;   // Anthropic nests one level deeper  if (err.status === 402) location.assign(info.upgrade_url);  else if (err.status === 401) startSignIn();  else if (err.status === 429) retryAfter(Number(err.headers?.get?.("retry-after") ?? 5));}

With @chabi/js, describeError reads any of these, from either SDK, into one shape with a plain English message:

import { describeError } from "@chabi/js"; } catch (err) {  const e = describeError(err);  if (e.kind === "out_of_credits") location.assign(e.upgradeUrl);  else if (e.kind === "app_limit") location.assign(e.manageUrl);  else showError(e.message);}

Limits

  • 20 requests a minute per user (across all apps), 300 a minute per app.
  • Request text up to 1 MB; audio files up to 25 MB.
  • PDFs and images go inline as base64 (a file or image_url part on /v1/chat/completions, a document or image block on /v1/messages), up to 20 MB per request. There is no files endpoint, so file_id isn't supported.
  • User tokens last 30 days; refresh tokens 90 days from their last use.

Endpoints

GET /oauth/authorize
Sign-in and consent screen. Redirects to your redirect URI with code and state, or error.
POST /oauth/token
Swaps the code, or a refresh token, for access_token and refresh_token (form-encoded or JSON).
POST /v1/chat/completions
OpenAI Chat Completions, for GPT models and every other vendor's models (ids like vendor/model). Streaming supported.
POST /v1/messages
Anthropic Messages, for Claude models. Streaming supported.
POST /v1/audio/transcriptions
OpenAI speech-to-text with gpt-transcribe. Uncompressed WAV only, up to 25 MB per file. See SPEECH TO TEXT.
POST /v1/audio/speech
OpenAI text to speech with gpt-realtime-2.1-mini, gpt-realtime-2.1 and OpenAI's voices. Streams mp3, opus, aac, flac, wav or pcm. See TEXT TO SPEECH.
POST /v1/images/generations
OpenAI-compatible image generation with any image model on the models page: prompt, and optionally n, size, quality, aspect_ratio, resolution, output_format, background, seed and input_references (images to edit or follow). Returns base64 images. No streaming, no URLs.
GET /v1/models
The models Chabi serves. With prices: /docs/models.
GET /v1/credits
The user's remaining credits.
GET /v1/me
The user's display name, or null if they haven't set one.