Examples
The repository ships two runnable examples that exercise the full agent loop.
mock_backend
Section titled “mock_backend”A complete, self-contained backend that streams a canned reply - no model or network needed. It’s the fastest way to see the event stream and tool loop run end to end.
cargo run --example mock_backendStart here to understand the shape of an LlmBackend
implementation and how events flow.
openai_backend
Section titled “openai_backend”A thin demo that drives the supported
OpenAiHttpBackend
against a streaming OpenAI-compatible endpoint. The same code works against:
- OpenAI
- llama.cpp’s
llama-server - vLLM
- LM Studio
- Ollama
# Chat endpoint (default):OPENAI_BASE_URL=http://localhost:8080/v1 OPENAI_MODEL=local \ cargo run --example openai_backend --features http-backend
# Completion endpoint (sends the already-templated prompt verbatim):OPENAI_BASE_URL=http://localhost:8080/v1 OPENAI_MODEL=local OPENAI_ENDPOINT=completions \ cargo run --example openai_backend --features http-backendThe backend lives behind the http-backend feature so its HTTP dependencies
don’t weigh on the core crate. Set OPENAI_API_KEY for a cloud endpoint.
Browse the source
Section titled “Browse the source”Both examples live in the
examples/ directory
on GitHub.