Skip to content

Errors

All errors from the Florentine API follow this consistent JSON structure:

json
{
  "error": {
    "name": "FlorentineApiError",
    "statusCode": 401,
    "message": "Please provide your Florentine API key. You can find it in your account settings: https://florentine.ai/settings",
    "errorCode": "NO_TOKEN",
    "requestId": "abc123"
  }
}
FieldTypeDescription
namestringError class name (e.g. FlorentineApiError, FlorentineConnectionError)
statusCodenumberHTTP status code (e.g. 400, 500)
messagestringExplanation of what went wrong
errorCodestringError identifier (e.g. NO_TOKEN, INVALID_LLM_KEY)
requestIdstringUnique ID for this request (helpful for support and debugging)

Node.js client error handling

When using the Node.js client, API errors are automatically thrown as JavaScript error classes:

ts
import { Florentine, FlorentineApiError } from "@florentine-ai/api";

try {
  const FlorentineAI = new Florentine({});
  const res: TFlorentineReturnOutput = await FlorentineAI.ask({
    question: "Who is Florentine?"
  });
} catch (err) {
  if (err instanceof FlorentineApiError) {
    console.error(err.message); // "Please provide your Florentine API key."
    console.error(err.statusCode); // 401
    console.error(err.errorCode); // "NO_TOKEN"
    console.error(err.requestId); // "abc123"
  }
}

All Node.js client errors extend the FlorentineError class, so you can catch all client related errors like this:

ts
if (err instanceof FlorentineError) {
  // Catches all florentine npm package errors
}

Common errors

Error TypeerrorCodeMeaning
FlorentineApiErrorNO_TOKENThe Florentine API key is missing
FlorentineApiErrorINVALID_TOKENThe Florentine API key is invalid
FlorentineApiErrorLLM_KEY_WITHOUT_SERVICEYou must provide a llmService if llmKey is defined
FlorentineApiErrorLLM_SERVICE_WITHOUT_KEYYou must provide a llmKey if llmService is defined
FlorentineApiErrorINVALID_LLM_SERVICEInvalid llmService provided
FlorentineApiErrorNO_OWN_LLM_KEYYou need to provide your own llm key
FlorentineApiErrorNO_ACTIVE_COLLECTIONSNo collections activated for the account
FlorentineApiErrorMISSING_REQUIRED_INPUTRequired input is missing
FlorentineApiErrorINVALID_REQUIRED_INPUTRequired input is invalid
FlorentineApiErrorINVALID_REQUIRED_INPUT_FORMATRequired input format is invalid
FlorentineApiErrorNO_QUESTIONQuestion is missing
FlorentineApiErrorEXECUTION_FAILURECreated aggregation execution failed
FlorentineApiErrorNO_CHAT_IDHistory chat id required but missing
FlorentineLLMErrorAPI_KEY_ISSUELLM API key is invalid
FlorentineLLMErrorNO_RETURNFlorentine.ai did not receive a valid LLM return
FlorentineLLMErrorRATE_LIMIT_EXCEEDEDLLM Request size too big
FlorentineApiErrorTOO_MANY_TOKENSThe aggregation prompt exceeds the maximum tokens of the LLM model
FlorentineConnectionErrorCONNECTION_REFUSEDCould not connect to database for aggregation execution
FlorentineCollectionErrorNO_EXECUTIONCreated aggregation could not be executed
FlorentinePipelineErrorMODIFICATION_FAILEDModifying the aggregation pipeline failed
FlorentineUsageErrorLIMIT_REACHEDAll API requests included in your plan depleted
FlorentineUnknownErrorUNKNOWN_ERRORAll occurring unknown errors