{"record":{"id":"1d01c7bbd4cb483b","repo":"Budibase/budibase","slug":"no-license-key-found","errorCode":null,"errorMessage":"No license key found","messagePattern":"No license key found","errorType":"http","errorClass":"HTTPError","httpStatus":422,"severity":"error","filePath":"packages/server/src/sdk/workspace/ai/configs/index.ts","lineNumber":195,"sourceCode":"    | \"reasoningEffort\"\n    | \"webSearchConfig\"\n    | \"name\"\n    | \"isDefault\"\n  >\n): Promise<CustomAIProviderConfig> {\n  const db = context.getWorkspaceDB()\n\n  const isBBAI = config.provider === BUDIBASE_AI_PROVIDER_ID\n  const isSelfhost = env.SELF_HOSTED\n\n  if (isBBAI && isSelfhost) {\n    const baseUrl = env.BUDICLOUD_URL.endsWith(\"/\")\n      ? env.BUDICLOUD_URL\n      : `${env.BUDICLOUD_URL}/`\n    config.credentialsFields.api_base = new URL(\"api/ai\", baseUrl).toString()\n    const licenseKey = await licensing.keys.getLicenseKey()\n    if (!licenseKey) {\n      throw new HTTPError(\"No license key found\", 422)\n    }\n    config.credentialsFields.api_key = licenseKey\n  }\n\n  const configId =\n    config.provider === BUDIBASE_AI_PROVIDER_ID\n      ? docIds.generateAIConfigID(\"bbai\")\n      : docIds.generateAIConfigID()\n\n  let modelId\n  if (!isBBAI || isSelfhost) {\n    const resolvedCredentialFields = await resolveCredentialFields(\n      config.credentialsFields\n    )\n\n    await liteLLM.validateConfig({\n      provider: config.provider,\n      name: config.model,","sourceCodeStart":177,"sourceCodeEnd":213,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/ai/configs/index.ts#L177-L213","documentation":"When creating an AI config that routes through Budibase Cloud, the server uses the workspace license key as the API key (api_key) against the BUDICLOUD_URL ai endpoint. If licensing.keys.getLicenseKey() returns nothing, it throws a 422 HTTPError because the cloud provider config cannot authenticate without a license.","triggerScenarios":"Creating/saving an AI config for the Budibase cloud provider on a self-hosted installation without an uploaded license key, or where the license is absent/expired so getLicenseKey() resolves null.","commonSituations":"Self-hosted Budibase (Docker/K8s) with no LICENSE_KEY set in the environment or license never activated; expired license removed by the worker; trying Budibase-hosted models without a paid plan.","solutions":["Upload/activate a valid license key so licensing.keys.getLicenseKey() returns a value (env LICENSE_KEY or license activation flow).","Use a non-cloud AI provider (e.g. OpenAI API key) instead of the Budibase cloud provider if no license is available.","Verify BUDICLOUD_URL and license sync with Budibase Cloud if a license should exist but is not resolving."],"exampleFix":"// before\n# .env (self-host, no license)\nawait sdk.ai.configs.create({ provider: BUDIBASE_AI_PROVIDER_ID, ... }) // 422\n// after\n# .env\nLICENSE_KEY=<valid-license>\n# or configure an alternative provider with its own api_key","handlingStrategy":"validation","validationCode":"const licenseKey = await licensing.keys.getLicenseKey()\nif (!licenseKey && config.provider === BUDIBASE_AI_PROVIDER_ID) {\n  throw new HTTPError(\"A license key is required for the Budibase cloud AI provider\", 422)\n}","typeGuard":"const canUseBudibaseCloudProvider = async (): Promise<boolean> =>\n  !!(await licensing.keys.getLicenseKey())","tryCatchPattern":"try {\n  await sdk.ai.configs.create({ provider: BUDIBASE_AI_PROVIDER_ID, ...config })\n} catch (err) {\n  if (err instanceof HTTPError && err.status === 422 && err.message === \"No license key found\") {\n    // instruct admin to activate a license or choose another provider\n  }\n}","preventionTips":["Set/activate LICENSE_KEY before offering the Budibase cloud AI provider on self-hosted installs.","Feature-gate the cloud provider option in the UI when no license is present.","Monitor license expiry and alert before cloud AI configs stop working."],"tags":["licensing","configuration","http-422"],"backgroundTag":"missing-license-key","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}