use freyja::{Agent, Client, EndpointPreset};
let client = Client::from_env(
EndpointPreset::OpenAi
)?;
let agent = Agent::new(client)
.system("Answer in one short sentence.");
let result = agent.ask("What is Rust?").await?;
println!("{}", result.answer);
Switch providers. Keep your agent.
cargo add freyjaRust 1.88 or laterPre-1.0, unstable API.
A path from
prompt to agent.
From first call to working agent.
Rust types in.
Tools out.
#[tool] derives the argument schema and executor. The agent runs the loop. Your storage keeps the transcript.
#[tool(description = "adds two numbers")]
fn add(a: i64, b: i64) -> i64 {
a + b
}
let agent = Agent::new(client)
.tool(add)
.memory(Window::last(20));