githubEdit

Setting requirements

Not all providers support every feature. Some might not support tool calling, others structured output, or file uploads. It's a good practice to ensure that you only send requests to providers that support all the features your request requires. To do this, just make sure to set the require_parameters parameter to true in your preferences.

require_param.rs
use orpheus::prelude::*;

fn main() {
    let client = Orpheus::from_env().unwrap();

    let calculator_tool = Tool::function("calculator")
        .description("Do an operation on two items")
        .with_parameters(|params| {
            params
                .property("x", Param::number())
                .property("y", Param::number())
                .property("op", Param::string().enums(["+", "-", "/", "*"]))
                .required(["x", "y", "op"])
        })
        .build();

    let res = client
        .chat("What is 42 + 39?")
        .model("qwen/qwen3-32b")
        .tools([calculator_tool])
        .with_preferences(|pref| pref.require_parameters(true)) // Will only send to providers that support tool calls
        .send()
        .unwrap();

    println!("Model says: {}", res.content().unwrap());
}

Last updated

Was this helpful?