Hello agent
This is the smallest troupekit program. In the hello example we define one agent with #[agent] and run it once. Its doc comment becomes the instructions.
use troupekit::prelude::*;
/// Greet the user by name.
#[agent(model = "openai/gpt-6-luna")]
fn greeter() {}
#[tokio::main]
async fn main() -> Result<(), KitError> {
println!("{}", greeter().run("I am Ada").await?);
Ok(())
}
Run it
export OPENAI_API_KEY="sk-..."
cargo run -p troupekit --example hello
The example needs the kit feature, which is on by default, and an OpenAI key.
What happens
greeter()returns anAgentnamedgreeterwhose instructions are the doc comment.runbuilds it: the selectoropenai/gpt-6-lunaresolves against the catalog and the key is read fromOPENAI_API_KEY.- One model call answers, and
runreturns the text.
Change the model
To try another vendor, change the selector. Any catalog selector works, such as anthropic/claude-haiku-5-5 with ANTHROPIC_API_KEY set. Models and providers lists the vendors.