{"record":{"id":"56d38198ddf774ab","repo":"Budibase/budibase","slug":"llm-not-available","errorCode":null,"errorMessage":"LLM not available","messagePattern":"LLM not available","errorType":"http","errorClass":"HTTPError","httpStatus":422,"severity":"error","filePath":"packages/pro/src/ai/generators/tableGeneration.ts","lineNumber":44,"sourceCode":"    tables: Record<string, TableSchemaFromAI>\n  ) => Promise<void>\n}\n\ntype ProgressCallback = (message: string) => void\n\nexport class TableGeneration {\n  private aiModel: LLMResponse\n\n  private delegates: Delegates\n\n  private constructor(aiModel: LLMResponse, delegates: Delegates) {\n    this.aiModel = aiModel\n    this.delegates = delegates\n  }\n\n  static async init(aiModel: LLMResponse, delegates: Delegates) {\n    if (!aiModel) {\n      throw new HTTPError(\"LLM not available\", 422)\n    }\n    return new TableGeneration(aiModel, delegates)\n  }\n\n  async generate(\n    userPrompt: string,\n    userId: string,\n    onProgress?: ProgressCallback\n  ) {\n    return tracer.trace(\"tableGeneration.generate\", async span => {\n      const tables = await this.generateTables(userPrompt, userId, onProgress)\n      span.addTags({ table_count: tables.length })\n      return tables\n    })\n  }\n\n  private llmFunctions = {\n    getTableStructure: async (","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/pro/src/ai/generators/tableGeneration.ts#L26-L62","documentation":"TableGeneration.init validates that an LLM configuration (aiModel) was resolved before constructing the generator. A missing/empty aiModel means there is no LLM available to perform AI table generation, so an HTTPError 422 is thrown early rather than failing mid-request.","triggerScenarios":"Calling the AI table generation endpoint (POST /api/ai/tables) on an instance where no LLM is configured, the AI provider config failed to load, or the resolved aiModel is null/undefined (no model selected or AI feature not enabled/licensed).","commonSituations":"Self-hosted Budibase without AI/LLM environment configuration, missing provider API keys, license without AI feature, LiteLLM/AI proxy not running or unreachable so the model lookup returns nothing.","solutions":["Configure an LLM for the instance (AI settings / provider API keys) and select a model.","Ensure the AI proxy (e.g. LiteLLM at localhost:4000 in dev) is running and reachable.","Verify the license includes the AI feature if it is license-gated.","Guard the UI so the AI table generation option is hidden when no model is available, instead of calling the endpoint."],"exampleFix":"// before\nconst tables = await generateTables({ prompt })\n// after\nconst model = await getAvailableLLM()\nif (!model) {\n  toast.error(\"No AI model configured for this instance\")\n  return\n}\nconst tables = await generateTables({ prompt })","handlingStrategy":"validation","validationCode":"const model = await getAvailableLLM()\nif (!model) throw new Error(\"Configure an AI model before using AI table generation\")","typeGuard":"function hasAIModel(model: LLMResponse | null | undefined): model is LLMResponse {\n  return model != null && typeof model === \"object\"\n}","tryCatchPattern":"try {\n  return await generateTables(req)\n} catch (e) {\n  if (e.status === 422 && e.message === \"LLM not available\") {\n    promptUserToConfigureAI()\n  } else throw e\n}","preventionTips":["Configure LLM provider and API keys at install time","Keep the AI proxy (LiteLLM) running in local dev","Hide AI features in the UI when no model is available","Confirm license entitlements for AI features"],"tags":["ai","llm","configuration","http-422"],"backgroundTag":"llm-not-configured","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}