Installation
How to add adk-rs to a project, which cargo feature flags exist, and which environment variables each provider reads.
adk-rs ships as a single crate whose default feature set is empty. You opt in to providers, storage backends, and subsystems with cargo features, so a minimal agent compiles only the dependencies it actually uses.
Add the dependency
Add adk-rs with the features you need. Almost every program wants at least one provider; most also want macros for the [#[tool]](/docs/function-tools) proc-macro.
cargo add adk-rs --features gemini,macros
cargo add tokio --features macros,rt-multi-thread
cargo add futures[dependencies]
adk-rs = { version = "0.6", features = ["gemini", "macros"] }
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
futures = "0.3"Feature flags
Every flag defined in the [features] section of Cargo.toml, and the optional dependencies it activates. Heavy dependencies (sqlx, axum, reqwest, OpenTelemetry) only compile when the matching feature is on.
| Feature | What it enables | Optional dependencies |
|---|---|---|
gemini | Gemini REST + SSE provider (providers::gemini). | reqwest, eventsource-stream |
anthropic | Anthropic Messages API + SSE provider. | reqwest, eventsource-stream |
openai | OpenAI-compatible provider; serves Azure OpenAI, Ollama, and Groq via base-URL override. | reqwest, eventsource-stream |
live | Gemini Live API — bidirectional WebSocket streaming; implies gemini. | tokio-tungstenite |
fs | Filesystem artifact service, path-traversal hardened. | none |
sqlite | SQL SessionService backed by SQLite. | sqlx (sqlite) |
postgres | SQL SessionService backed by PostgreSQL. | sqlx (postgres) |
mcp | MCP toolset — stdio and streamable-HTTP transports. | reqwest, eventsource-stream |
telemetry | tracing setup via tracing-subscriber. | tracing-subscriber |
otel | OpenTelemetry OTLP export; implies telemetry. | opentelemetry, opentelemetry_sdk, opentelemetry-otlp, tracing-opentelemetry |
eval | Evaluation framework — eval-set replay and scoring. | none |
server | axum dev server with SSE, bearer auth, loopback guard. | axum, tower, tower-http, http |
cli | Embeddable clap CLI; implies telemetry, server, eval. | clap |
macros | The #[tool] proc-macro from the sibling adk-rs-macros crate. | adk-rs-macros |
auth | Credential flows: OAuth2, service-account JWTs, API keys. | reqwest, oauth2, jsonwebtoken, rand |
openapi | OpenAPI 3.x tool generator. | reqwest, openapiv3, serde_yaml |
code-exec | Local-subprocess code executor. | none |
code-exec-docker | Locked-down Docker container executor; implies code-exec. | none (docker CLI on $PATH) |
a2a | Agent-to-Agent JSON-RPC client + server bridge. | reqwest, eventsource-stream, axum, tower, tower-http, http |
testing | Test helpers such as adk_rs::core::testing::MockModel for use outside the crate. See Testing. | none |
full | Convenience superset — see the note below. | everything above |
Provider credentials
Each provider has a from_env constructor that reads its API key from the environment and fails with a configuration error when the variable is missing or empty.
| Provider | Constructor | Environment variables |
|---|---|---|
| Gemini | Gemini::from_env(model) | GOOGLE_API_KEY |
| Anthropic | Anthropic::from_env(model) | ANTHROPIC_API_KEY |
| OpenAI-compatible | OpenAi::from_env(model) | OPENAI_API_KEY, plus optional OPENAI_BASE_URL (defaults to https://api.openai.com/v1) |
Setting OPENAI_BASE_URL is how you point the OpenAI client at Azure OpenAI, Ollama, Groq, or any other OpenAI-compatible endpoint. All provider clients enforce HTTPS-or-loopback for the base URL — see Security.
Toolchain requirements
- MSRV: Rust 1.85 (
rust-version = "1.85"in the manifest), edition 2024. - The repository pins
channel = "1.85.0"inrust-toolchain.toml, withrustfmt,clippy, andrust-srccomponents. - The async runtime is
tokio; event streams are ordinaryfutures::Streams, so you also want thefuturescrate forStreamExt.
Where next
- Quickstart — build and run your first agent end to end.
- Providers — Gemini, Anthropic, and OpenAI-compatible clients in depth.
- Introduction — design overview and crate layout.