Beta

This API is in beta. Endpoints, request/response formats, and behavior may change without notice.

API Reference

Terramind Documentation

Response Headers

All API responses include the following headers:

HeaderDescription
X-Request-IdUnique request identifier for debugging
X-RateLimit-LimitMaximum requests per minute (60)
X-RateLimit-RemainingRemaining requests in the current window
X-RateLimit-ResetUnix timestamp (seconds) when the rate limit resets
X-CacheHIT or MISS (only present when cache: true)
X-Model-IdThe model that actually served the request (only present when a fallback model was used)

Rate limit headers are included for API key requests only, not browser session requests.

Rate Limits & Billing

  • 60 requests per minute per API key
  • Credits are deducted from your organization's balance (not per-user)
  • When rate limited, you'll receive a 429 response with a Retry-After header (value in seconds)
  • Max 10 active API keys per user
  • Pricing varies by model. Use the Models endpoint to see per-model costs.

Error Codes

CodeMeaning
400Invalid request (missing model, empty messages, invalid parameters, context overflow)
401Invalid or expired API key
402Insufficient credits
403Model requires a paid plan / no organization
408Request timed out (all models exceeded the timeout)
429Rate limit exceeded, OR the organization has hit its 6-hour usage window. Window errors carry error code WINDOW_EXHAUSTED and include resetAt (ISO-8601). Buy top-up credits to continue immediately, or wait for the window to roll over.
500Internal server error
502All models failed (primary + all fallbacks exhausted)

Credit Reservation

To prevent concurrent requests from overselling the same balance, every billed endpoint reserves credits up-front before starting work. The reservation is settled on completion:

  • Success — the reservation is converted into a charge (exact token cost for chat, fixed tier cost for image/video).
  • Failure — the reservation is released and the balance is untouched (provider error, invalid input, download failure, webhook delivery failure, etc.).
  • Queued image/video jobs (202 Accepted) — the reservation stays held until the fal webhook fires; a successful delivery charges, a failed delivery releases.

The practical impact for callers: a 402 or 429 returned before work starts means zero credits were used; balance changes are visible only after a successful response or webhook.

OpenAI-Compatible Error Types

The /v1/chat/completions endpoint wraps errors in an OpenAI-shaped envelope:

{ "error": { "message": "…", "type": "rate_limit_exceeded" } }
Statustype
400invalid_request_error
401invalid_request_error
402insufficient_quota
429rate_limit_exceeded
5xxapi_error