{"record":{"id":"32614c42de270de1","repo":"nexu-io/open-design","slug":"no-openai-credential-configure-an-api-key-in-set","errorCode":null,"errorMessage":"no OpenAI credential - configure an API key in Settings or set OPENAI_API_KEY.","messagePattern":"no OpenAI credential - configure an API key in Settings or set OPENAI_API_KEY\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/daemon/src/media/index.ts","lineNumber":900,"sourceCode":"  bodyTimeout: OPENAI_IMAGE_BODY_TIMEOUT_MS,\n});\n\nfunction withMediaRequestInit(\n  ctx: Pick<MediaContext, 'requestInit'>,\n  init: RequestInit = {},\n): RequestInit {\n  return {\n    ...ctx.requestInit,\n    ...init,\n  };\n}\n\nconst OPENAI_IMAGE_NO_CREDENTIAL_MESSAGE =\n  'no OpenAI credential - configure an API key in Settings or set OPENAI_API_KEY.';\n\nasync function renderOpenAIImage(ctx: MediaContext, credentials: ProviderConfig): Promise<RenderResult> {\n  if (!credentials.apiKey) {\n    throw new Error(OPENAI_IMAGE_NO_CREDENTIAL_MESSAGE);\n  }\n  const rawBase = credentials.baseUrl || 'https://api.openai.com/v1';\n  const azure = detectAzureEndpoint(rawBase);\n  const url = buildOpenAIImageUrl(rawBase, azure);\n\n  const body: Record<string, unknown> = {\n    prompt: ctx.prompt || 'A high-quality reference image.',\n    n: 1,\n    size: openaiSizeFor(ctx.model, ctx.aspect),\n  };\n  // For non-Azure calls, include `model` in the body. Azure infers it\n  // from the deployment in the path so omitting it keeps payloads\n  // compatible across both flavors. The wire-name (post-alias) goes\n  // on the body so the user's alias from issue #1277 reaches the API.\n  if (!azure) {\n    body.model = ctx.wireModel;\n  }\n  // Capability branches key off the CATALOG id (not the alias) so a","sourceCodeStart":882,"sourceCodeEnd":918,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/media/index.ts#L882-L918","documentation":"Thrown at the top of renderOpenAIImage when credentials.apiKey is falsy. The renderer needs a Bearer key to call POST {baseUrl}/v1/images/generations (or the Azure deployment path); without one it refuses before any network call. The constant OPENAI_IMAGE_NO_CREDENTIAL_MESSAGE is reused so the same text reaches image and (via a sibling check) other OpenAI surfaces.","triggerScenarios":"Selecting an OpenAI image model (dall-e-*, gpt-image-*) with no OpenAI provider credential stored and no OPENAI_API_KEY env var; credentials saved under a different provider key; Settings page saved an empty key.","commonSituations":"Fresh install; user moved env vars out of the shell rc; key was deleted from the credentials store but the UI still shows the model as selectable; BYOK path where the daemon process does not inherit the user's shell env.","solutions":["Set OPENAI_API_KEY in the daemon's environment, or add the key under Settings -> Media Providers -> OpenAI.","If using Azure OpenAI, populate the same apiKey field with the Azure deployment key (baseUrl drives the Azure detection).","Restart the daemon after setting the env var so the new value is read.","Verify with od media providers (or the settings UI) that the OpenAI row shows a configured key."],"exampleFix":"// before\nod media generate --surface image --model dall-e-3 --prompt \"...\"\n// after\nexport OPENAI_API_KEY=sk-...\nod media generate --surface image --model dall-e-3 --prompt \"...\"","handlingStrategy":"validation","validationCode":"function ensureOpenAICredential(creds: {apiKey?: string} | null): asserts creds is { apiKey: string } {\n  if (!creds?.apiKey) {\n    throw new Error('no OpenAI credential - configure an API key in Settings or set OPENAI_API_KEY.');\n  }\n}\nensureOpenAICredential(credentials);","typeGuard":"function hasOpenAIKey(c: {apiKey?:string} | null): c is { apiKey: string } {\n  return Boolean(c && typeof c.apiKey === 'string' && c.apiKey.length > 0);\n}","tryCatchPattern":null,"preventionTips":["Pre-flight the OpenAI credential in the UI/CLI before listing dall-e/gpt-image models as runnable.","Surface a missing-key badge next to OpenAI-dependent models in the picker.","Document that the daemon process must have OPENAI_API_KEY exported (BYOK runs do not inherit login shell env)."],"tags":["media","provider-config","openai","credentials","image"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}