{"record":{"id":"ca865546beef568d","repo":"BoundaryML/baml","slug":"base-url-is-required","errorCode":null,"errorMessage":"base_url is required","messagePattern":"base_url is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-lib/llm-client/src/clients/openai.rs","lineNumber":189,"sourceCode":"        ctx: &impl GetEnvVar,\n    ) -> Result<ResolvedOpenAI> {\n        let base_url = self\n            .base_url\n            .as_ref()\n            .map(|url| match url {\n                either::Either::Left(url) => url.resolve(ctx),\n                either::Either::Right((resource_name, deployment_id)) => {\n                    let resource_name = resource_name.resolve(ctx)?;\n                    let deployment_id = deployment_id.resolve(ctx)?;\n                    Ok(format!(\n                        \"https://{resource_name}.openai.azure.com/openai/deployments/{deployment_id}\"\n                    ))\n                }\n            })\n            .transpose()?;\n\n        let Some(base_url) = base_url else {\n            return Err(anyhow::anyhow!(\"base_url is required\"));\n        };\n\n        let api_key = self\n            .api_key\n            .as_ref()\n            .map(|key| key.resolve_api_key(ctx))\n            .transpose()?;\n\n        let role_selection = self.role_selection.resolve(ctx)?;\n\n        let headers = self\n            .headers\n            .iter()\n            .map(|(k, v)| Ok((k.clone(), v.resolve(ctx)?)))\n            .collect::<Result<IndexMap<_, _>>>()?;\n\n        let properties = {\n            let mut properties = self","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-lib/llm-client/src/clients/openai.rs#L171-L207","documentation":"The openai client variant being resolved (a generic/base-url-driven variant) requires a `base_url` option. After resolving the configured value, a None base_url aborts with \"base_url is required\" since these variants have no default endpoint.","triggerScenarios":"Using an openai-generic/openai-compatible provider without setting `base_url`; base_url expression resolving to None (missing env var); constructing OpenAi client struct programmatically without base_url.","commonSituations":"Pointing at a self-hosted OpenAI-compatible server (vLLM, LM Studio) and forgetting base_url; env-var interpolation failing so base_url resolves empty/None; using the generic variant instead of the built-in openai provider that has a default URL.","solutions":["Add `base_url \"https://your-endpoint/v1\"` to the client options.","Ensure the env var referenced in base_url is exported and non-empty.","If you intended the standard OpenAI API, switch to provider \"openai\" which has a default base URL."],"exampleFix":"// before\nclient \"Local\" {\n  provider \"openai-generic\"\n  options { model \"llama3\" }\n}\n// after\nclient \"Local\" {\n  provider \"openai-generic\"\n  options {\n    model \"llama3\"\n    base_url \"http://localhost:11434/v1\"\n  }\n}","handlingStrategy":"validation","validationCode":"if cfg.base_url.is_none() && requires_base_url(cfg.provider) { panic!(\"base_url is required for this provider variant\"); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set base_url for openai-generic/openrouter/ollama-style clients.","Confirm interpolated env vars (e.g. ${BASE_URL}) are exported before running.","Use provider \"openai\" if you want the default OpenAI endpoint instead of generic."],"tags":["openai","base-url","missing-field"],"backgroundTag":"missing-required-config-field","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}