BoundaryML/baml · error
baml.media.image.from_url expects 1 argument, got {} at {:?}
Error message
baml.media.image.from_url expects 1 argument, got {} at {:?} What it means
Thrown by the BAML interpreter's builtin-function evaluator when `baml.media.image.from_url` is called with an argument count other than exactly 1. The builtin constructs an image BamlMedia from a URL and requires exactly one string argument.
Source
Thrown at engine/baml-compiler/src/thir/interpret.rs:2716
}
Ok(BamlValueWithMeta::Map(baml_map, meta.clone()))
}
}
}
json_to_baml(&json_value, target_type, meta)
}
async fn evaluate_builtin_function(
fn_name: &str,
args: &[BamlValueWithMeta<ExprMetadata>],
type_args: &[baml_types::TypeIR],
meta: &ExprMetadata,
) -> Result<BamlValueWithMeta<ExprMetadata>> {
match fn_name {
"baml.media.image.from_url" => {
if args.len() != 1 {
bail!(
"baml.media.image.from_url expects 1 argument, got {} at {:?}",
args.len(),
meta.0
);
}
let url = match &args[0] {
BamlValueWithMeta::String(s, _) => s.clone(),
_ => bail!(
"baml.media.image.from_url expects a string argument at {:?}",
meta.0
),
};
Ok(BamlValueWithMeta::Media(
baml_types::BamlMedia::url(baml_types::BamlMediaType::Image, url, None),
meta.clone(),
))
}
"baml.fetch_as" => {View on GitHub (pinned to bd85ce9dee)
Solutions
- Call baml.media.image.from_url with exactly one string URL argument
- Move any extra configuration (headers, alt text) out of the builtin call; it only accepts a URL
- Check arity at the call site; count arguments if they are generated dynamically (e.g. spread from a list)
- Consult the builtin registry for media builtins that accept extra parameters if you need them
Example fix
// before (BAML) let img = baml.media.image.from_url(url, "logo"); // after let img = baml.media.image.from_url(url);
Defensive patterns
Strategy: validation
Validate before calling
function validateImageFromUrlArgs(args: unknown[]): void {
if (args.length !== 1) {
throw new Error(`baml.media.image.from_url expects 1 argument, got ${args.length}`);
}
if (typeof args[0] !== 'string') {
throw new Error('baml.media.image.from_url expects a string URL');
}
} Try / catch
try {
img = evaluate(call);
} catch (e) {
if (String(e).includes('baml.media.image.from_url expects 1 argument')) {
// trim extra args at the call site
}
throw e;
} Prevention
- Check builtin arity in docs before adding options
- Never spread variable-length arg lists into builtins
- Keep media configuration out of positional builtin arguments
When it happens
Trigger: Calling baml.media.image.from_url with 0 arguments, or with 2+ arguments (e.g. trying to pass url plus alt-text or dimensions, which this builtin does not accept).
Common situations: Copying a media-helper signature from another API that accepts options, adding extra positional parameters, or forgetting the url argument entirely when constructing dynamic media in prompt expressions.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- env.get expects exactly one argument
- baml.media.image.from_url expects a string argument at {:?}
- baml.fetch_as expects 1 argument (url), got {} at {:?}
- env.get argument must be a string
- length() method takes no arguments at {:?}
AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12).
Data as JSON: /api/errors/8d01cd6aeb69a414.
Report an issue: GitHub.