Skip to content

Examples

The repository ships two runnable examples that exercise the full agent loop.

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.

Terminal window
cargo run --example mock_backend

Start here to understand the shape of an LlmBackend implementation and how events flow.

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
Terminal window
# 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-backend

The 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.

Both examples live in the examples/ directory on GitHub.