DOCS / API REFERENCE / ERRORS

Errors

Every error response — from both /v1 and /management/v1 — uses the same envelope, deliberately shaped like OpenAI's error format for client compatibility:

json
Authorization: Bearer lattice_sk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
messagestring
Human-readable. For unhandled/unexpected exceptions this is always replaced with the generic "Internal server error" — internal error text and stack traces never reach the client. See Security.
typestring
A coarse OpenAI-style category, derived purely from the HTTP status — not a stable identifier on its own, prefer code for programmatic handling.
codestring | null
A stable LatticeErrorCode. null only for errors the gateway didn't classify (unexpected exceptions).

type derivation

HTTP statustype
401authentication_error
403permission_error
404not_found_error
429rate_limit_error
>= 500upstream_error
anything elseinvalid_request_error

Every error code

codeStatusMeaning
missing_api_key401No Authorization header, or it isn't Bearer <token>.
invalid_api_key401The key doesn't match any active key, or (for application keys) the owning application is disabled.
revoked_api_key401Reserved for explicit revocation-specific messaging.
model_not_found404model matches no registry id or alias.
model_not_permitted403The application's allowedModels list doesn't include the requested model.
unsupported_parameter400Reserved for parameter-specific rejection messaging.
invalid_request400Body failed JSON parsing or schema validation (strict — unknown fields included), or a query parameter (e.g. days, limit, offset, status) was out of range.
quota_exceeded429The application's monthlyTokenQuota is exhausted.
rate_limit_exceeded429The application's rateLimitPerMinute is exceeded for the current 60-second window.
provider_error502A single-candidate dispatch failed, or an adapter was invoked with no resolvable credentials (should be unreachable given registry validation).
all_providers_failed502Every candidate in the resolved provider chain failed.
model_registry_invalid—Boot-time only — the process refuses to start with an invalid models.config.ts. Never returned to a client.
invalid_env—Boot-time only — the process refuses to start with invalid/missing environment variables. Never returned to a client.
not_found404A management API resource (application, API key) doesn't exist.
internal_error500Reserved for explicitly classified internal failures.
NOTE
Any exception that isn't explicitly thrown as one of the codes above still gets a response — status 500, type: "upstream_error" is not guaranteed, code: null, message: "Internal server error". Treat code: null as "unclassified failure, safe to retry with backoff," the same way you'd treat an unexpected 500 from any other API.

Handling errors as a client

ts
type ProviderAdapter = {
  id: ProviderId;
  createChatCompletion(
    request: ChatCompletionRequest,
    ctx: ProviderRequestContext,
  ): Promise<ChatCompletionResponse>;
  streamChatCompletion(
    request: ChatCompletionRequest,
    ctx: ProviderRequestContext,
  ): AsyncGenerator<ChatCompletionChunk, void, void>;
};

type ProviderRequestContext = {
  apiKey?: string;
  providerModel: string;
  signal: AbortSignal;
};
LATTICE — INTERNAL AI INFRASTRUCTURE
GITHUB © 2026