{"record":{"id":"774c631acbb0ec6c","repo":"can1357/oh-my-pi","slug":"provider-providername-baseurl-is-required-wh","errorCode":null,"errorMessage":"Provider ${providerName}: \"baseUrl\" is required when defining custom models.","messagePattern":"Provider (.+?): \"baseUrl\" is required when defining custom models\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/config/models-config.ts","lineNumber":66,"sourceCode":"\t\t\t\t!config.baseUrl &&\n\t\t\t\t!config.headers &&\n\t\t\t\t!config.compat &&\n\t\t\t\t!config.apiKey &&\n\t\t\t\tconfig.auth !== \"none\" &&\n\t\t\t\t!config.disableStrictTools &&\n\t\t\t\t!config.guardrailIdentifier &&\n\t\t\t\t!config.remoteCompaction &&\n\t\t\t\t!hasModelOverrides &&\n\t\t\t\t!config.discovery\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Provider ${providerName}: must specify \"baseUrl\", \"headers\", \"apiKey\", \"auth: none\", \"compat\", \"disableStrictTools\", \"guardrailIdentifier\", \"remoteCompaction\", \"modelOverrides\", \"discovery\", or \"models\"`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif (!config.baseUrl) {\n\t\t\tthrow new Error(`Provider ${providerName}: \"baseUrl\" is required when defining custom models.`);\n\t\t}\n\t\tconst requiresAuth =\n\t\t\tmode === \"runtime-register\"\n\t\t\t\t? !config.apiKey && !config.oauthConfigured\n\t\t\t\t: !config.apiKey && (config.auth ?? \"apiKey\") !== \"none\" && (config.auth ?? \"apiKey\") !== \"oauth\";\n\t\tif (requiresAuth) {\n\t\t\tthrow new Error(\n\t\t\t\tmode === \"runtime-register\"\n\t\t\t\t\t? `Provider ${providerName}: \"apiKey\" or \"oauth\" is required when defining models.`\n\t\t\t\t\t: `Provider ${providerName}: \"apiKey\" is required when defining custom models unless auth is \"none\" or \"oauth\".`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (mode === \"models-config\" && config.discovery && !config.api && config.discovery.type !== \"proxy\") {\n\t\tthrow new Error(`Provider ${providerName}: \"api\" is required when discovery is enabled at provider level.`);\n\t}\n","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/config/models-config.ts#L48-L84","documentation":"In models-config/runtime mode, validateProviderConfiguration requires `baseUrl` whenever the provider defines custom `models`. Models need an endpoint to send requests to; a provider with a models list but no baseUrl cannot construct request URLs, so the error is thrown naming the provider.","triggerScenarios":"registerProvider or ModelsConfigFile validation with `{ models: [...] }` (or modelOverrides implying models) but no `config.baseUrl` — for example defining model ids under a provider whose baseUrl line was forgotten or deleted.","commonSituations":"Copying a provider block and removing baseUrl because 'the hosted API has a known URL' (the library does not infer it for custom providers); refactoring shared config where baseUrl moved to a different key; typo `baseURL`/`base_url` instead of `baseUrl`.","solutions":["Add `baseUrl` to the provider config (typically ending in /v1 for OpenAI-compatible backends).","Check the key spelling is exactly `baseUrl` (camelCase), not baseURL or base_url.","If models were listed only to override metadata of a bundled provider, use `modelOverrides` on the named provider instead of a fresh custom provider without baseUrl."],"exampleFix":"// before\n{ \"provider\": \"gw\", \"apiKey\": \"sk-...\", \"models\": [{ \"id\": \"mini\" }] }\n// after\n{ \"provider\": \"gw\", \"baseUrl\": \"https://gw.example.com/v1\", \"apiKey\": \"sk-...\", \"models\": [{ \"id\": \"mini\" }] }","handlingStrategy":"validation","validationCode":"if (cfg.models?.length && !cfg.baseUrl) {\n  throw new Error(`Provider ${cfg.provider}: add \"baseUrl\" when listing models`);\n}","typeGuard":"function hasBaseUrlForModels(cfg: { baseUrl?: string; models?: unknown[] }): cfg is { baseUrl: string; models?: unknown[] } {\n  return !(cfg.models?.length) || typeof cfg.baseUrl === \"string\" && cfg.baseUrl.length > 0;\n}","tryCatchPattern":"try {\n  modelsConfig.apply(parsed);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('\"baseUrl\" is required when defining custom models')) {\n    const provider = err.message.match(/Provider ([^:]+):/)?.[1];\n    throw new Error(`Add baseUrl to provider \"${provider}\" in your models config`);\n  }\n  throw err;\n}","preventionTips":["Always write baseUrl next to models in the same provider block.","Use the exact camelCase key `baseUrl`; baseURL/base_url silently fail validation.","For bundled/hosted providers use modelOverrides rather than redefining models without a URL.","Schema-validate config files before loading them."],"tags":["configuration","validation","models-config","base-url"],"backgroundTag":"missing-required-config-field","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}