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.

bashbash
cargo add adk-rs --features gemini,macros
cargo add tokio --features macros,rt-multi-thread
cargo add futures
Cargo.tomltoml
[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.

FeatureWhat it enablesOptional dependencies
geminiGemini REST + SSE provider (providers::gemini).reqwest, eventsource-stream
anthropicAnthropic Messages API + SSE provider.reqwest, eventsource-stream
openaiOpenAI-compatible provider; serves Azure OpenAI, Ollama, and Groq via base-URL override.reqwest, eventsource-stream
liveGemini Live API — bidirectional WebSocket streaming; implies gemini.tokio-tungstenite
fsFilesystem artifact service, path-traversal hardened.none
sqliteSQL SessionService backed by SQLite.sqlx (sqlite)
postgresSQL SessionService backed by PostgreSQL.sqlx (postgres)
mcpMCP toolset — stdio and streamable-HTTP transports.reqwest, eventsource-stream
telemetrytracing setup via tracing-subscriber.tracing-subscriber
otelOpenTelemetry OTLP export; implies telemetry.opentelemetry, opentelemetry_sdk, opentelemetry-otlp, tracing-opentelemetry
evalEvaluation framework — eval-set replay and scoring.none
serveraxum dev server with SSE, bearer auth, loopback guard.axum, tower, tower-http, http
cliEmbeddable clap CLI; implies telemetry, server, eval.clap
macrosThe #[tool] proc-macro from the sibling adk-rs-macros crate.adk-rs-macros
authCredential flows: OAuth2, service-account JWTs, API keys.reqwest, oauth2, jsonwebtoken, rand
openapiOpenAPI 3.x tool generator.reqwest, openapiv3, serde_yaml
code-execLocal-subprocess code executor.none
code-exec-dockerLocked-down Docker container executor; implies code-exec.none (docker CLI on $PATH)
a2aAgent-to-Agent JSON-RPC client + server bridge.reqwest, eventsource-stream, axum, tower, tower-http, http
testingTest helpers such as adk_rs::core::testing::MockModel for use outside the crate. See Testing.none
fullConvenience 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.

ProviderConstructorEnvironment variables
GeminiGemini::from_env(model)GOOGLE_API_KEY
AnthropicAnthropic::from_env(model)ANTHROPIC_API_KEY
OpenAI-compatibleOpenAi::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" in rust-toolchain.toml, with rustfmt, clippy, and rust-src components.
  • The async runtime is tokio; event streams are ordinary futures::Streams, so you also want the futures crate for StreamExt.

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.