Skip to content

Error handling

LLM Engine uses conventional HTTP response codes to indicate the success or failure of an API request. In general: codes in the 2xx range indicate success. Codes in the 4xx range indicate indicate an error that failed given the information provided (e.g. a given Model was not found, or an invalid temperature was specified). Codes in the 5xx range indicate an error with the LLM Engine servers.

In the Python client, errors are presented via a set of corresponding Exception classes, which should be caught and handled by the user accordingly.

BadRequestError

BadRequestError(message: str)

Bases: Exception

Corresponds to HTTP 400. Indicates that the request had inputs that were invalid. The user should not attempt to retry the request without changing the inputs.

UnauthorizedError

UnauthorizedError(message: str)

Bases: Exception

Corresponds to HTTP 401. This means that no valid API key was provided.

NotFoundError

NotFoundError(message: str)

Bases: Exception

Corresponds to HTTP 404. This means that the resource (e.g. a Model, FineTune, etc.) could not be found. Note that this can also be returned in some cases where the object might exist, but the user does not have access to the object. This is done to avoid leaking information about the existence or nonexistence of said object that the user does not have access to.

RateLimitExceededError

RateLimitExceededError(message: str)

Bases: Exception

Corresponds to HTTP 429. Too many requests hit the API too quickly. We recommend an exponential backoff for retries.

ServerError

ServerError(status_code: int, message: str)

Bases: Exception

Corresponds to HTTP 5xx errors on the server.