Page cover image

Errors

HTTP errors

Our API utilizes standard HTTP status codes to indicate errors:

  • 400: The API key is invalid, or the requested model is not supported.

  • 429: Your account or API key has run out of balance. Please add funds and try again.

Provider errors

In case of an error from the model provider, the error.metadata will contain relevant details. The format of this metadata is outlined below:

type ProviderErrorMetadata = {
  provider_name: string; // The name of the provider that encountered the error
  raw: unknown; // The raw error from the provider
};

Error format

Errors are always returned as JSON, with the following structure:

type ErrorResponse = {
  error: {
    code: number;
    message: string;
    metadata?: Record<string, unknown>;
  };
};

The HTTP status code in the response will correspond to the error.code. Errors will occur under the following circumstances:

  • The request is invalid.

  • The API key/account has insufficient balance.

  • The API key is invalid.

If no issues are found, the response will return a 200 OK status. Any errors encountered during LLM processing will be included in the response body or sent as an SSE data event.

Last updated