BoundaryML/baml · error · anyhow::Error
Function has no client
Error message
Function {} has no client What it means
The IR walker raises this when a BAML function has no client configured at all, while trying to compute the environment variables the function needs (required_env_vars). Every BAML function must reference a client so the compiler knows which provider/credentials to use.
Solutions
- Add a `client <ClientName>` line to the function block in your .baml file
- Define a client in a clients block if none exists, then reference it from the function
- Re-run generation/validation after adding the client to confirm required env vars resolve
Example fix
// before
function Summarize(text: string) {
prompt #"..."#
}
// after
function Summarize(text: string) {
client Gpt4o
prompt #"..."#
} Defensive patterns
Strategy: validation
Validate before calling
// Ensure every function has a client before calling required_env_vars
for func in &functions {
if func.client.is_none() {
bail!("function {} must declare a client", func.name);
}
} Prevention
- Never create a function block without a client line
- Use templates/snippets that include the client field
- Run baml-cli validate on every commit
When it happens
Trigger: Calling required_env_vars() on a Walker for a function whose definition omits the `client` field, or whose function block fails to declare any client reference.
Common situations: Newly created function blocks where the developer forgot the `client` line; generated functions from templates that omit clients; copying a function body without its client directive.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- {e.message()}
- default_role must be one of 'system', 'user' or 'assistant
- Either base_url or both (resource_name, deployment_id) must…
- Expected a map
- Expected a statically defined string, not env variable
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/0bd0f84a81e345f1.
Report an issue: GitHub.
Appendix: source
Thrown at engine/baml-lib/baml-core/src/ir/walker.rs:118
(
(),
baml_types::UnresolvedValue::String(
baml_types::StringOr::Value(model.clone()),
(),
),
),
)]);
let properties = internal_llm_client::PropertyHandler::<()>::new(options, ());
if let Ok(client) = provider.parse_client_property(properties) {
Ok(client.required_env_vars())
} else {
// We likely can't make a shorthand client from the given provider
Ok(HashSet::new())
}
}
}
} else {
anyhow::bail!("Function {} has no client", self.name())
}
}
pub fn walk_impls(
&'a self,
) -> impl Iterator<Item = Walker<'a, (&'a repr::Function, &'a FunctionConfig)>> {
self.elem().configs.iter().map(|c| Walker {
ir: self.ir,
item: (self.elem(), c),
})
}
pub fn walk_tests(
&'a self,
) -> impl Iterator<Item = Walker<'a, (&'a FunctionNode, &'a TestCase)>> {
self.elem().tests().iter().map(|i| Walker {
ir: self.ir,
item: (self.item, i),
})View on GitHub (pinned to bd85ce9dee)