pub struct AnthropicConfig {Show 15 fields
pub api_key: String,
pub model: String,
pub max_tokens: u32,
pub base_url: Option<String>,
pub prompt_caching: bool,
pub thinking: Option<ThinkingMode>,
pub effort: Option<Effort>,
pub fast_mode: bool,
pub citations: bool,
pub inference_geo: Option<String>,
pub context_management: Option<ContextManagement>,
pub service_tier: Option<String>,
pub beta_features: Vec<String>,
pub api_version: Option<String>,
pub tool_search: Option<ToolSearchConfig>,
}anthropic only.Expand description
Configuration for Anthropic API.
§Example
use adk_model::anthropic::{AnthropicConfig, ThinkingMode, Effort};
// Opus 4.7 with adaptive thinking and xhigh effort (recommended)
let config = AnthropicConfig::new("sk-ant-xxx", "claude-opus-4-7")
.with_thinking_mode(ThinkingMode::Adaptive)
.with_effort(Effort::XHigh);
// Adaptive thinking with medium effort (recommended for Sonnet 4.6)
let config = AnthropicConfig::new("sk-ant-xxx", "claude-sonnet-4-6")
.with_thinking_mode(ThinkingMode::Adaptive)
.with_effort(Effort::Medium);
// Budget-based thinking (legacy, rejected on Opus 4.7)
let config = AnthropicConfig::new("sk-ant-xxx", "claude-sonnet-4-5")
.with_thinking_mode(ThinkingMode::Enabled { budget_tokens: 8192 });
// Prompt caching (enabled by default, can be disabled)
let config = AnthropicConfig::new("sk-ant-xxx", "claude-sonnet-4-6")
.with_prompt_caching(false); // opt outFields§
§api_key: StringAnthropic API key.
model: StringModel name (e.g., "claude-opus-4-7", "claude-sonnet-4-6").
max_tokens: u32Maximum tokens to generate.
base_url: Option<String>Optional custom base URL (for proxies, Ollama, Vercel Gateway, etc.).
prompt_caching: boolEnable prompt caching with cache_control blocks.
Defaults to true. Anthropic prompt caching reduces costs and latency
by reusing previously processed context. Disable with
with_prompt_caching(false).
thinking: Option<ThinkingMode>Thinking mode configuration.
effort: Option<Effort>Effort level (goes into output_config.effort).
Works with or without thinking enabled.
fast_mode: boolEnable fast mode (Opus 4.6+ only, beta). Delivers up to 2.5× higher output tokens/sec at 6× pricing.
citations: boolEnable citations on documents in requests.
inference_geo: Option<String>Geographic routing for data residency (e.g., "US", "EU").
context_management: Option<ContextManagement>Server-side context management (tool result clearing, thinking block clearing). Requires beta header (auto-injected by adk-anthropic).
service_tier: Option<String>Service tier ("auto" or "standard_only").
beta_features: Vec<String>Beta feature headers (e.g., "prompt-caching-2024-07-31").
api_version: Option<String>Custom API version header override.
tool_search: Option<ToolSearchConfig>Tool search configuration for regex-based dynamic tool discovery.
When set, only tools whose names match the regex pattern are loaded.
When None, all available tools are loaded.
Implementations§
Source§impl AnthropicConfig
impl AnthropicConfig
Sourcepub fn new(
api_key: impl Into<String>,
model: impl Into<String>,
) -> AnthropicConfig
Available on crate feature models only.
pub fn new( api_key: impl Into<String>, model: impl Into<String>, ) -> AnthropicConfig
models only.Create a new Anthropic config with the given API key and model.
Sourcepub fn with_max_tokens(self, max_tokens: u32) -> AnthropicConfig
Available on crate feature models only.
pub fn with_max_tokens(self, max_tokens: u32) -> AnthropicConfig
models only.Set the maximum tokens to generate.
Sourcepub fn with_base_url(self, base_url: impl Into<String>) -> AnthropicConfig
Available on crate feature models only.
pub fn with_base_url(self, base_url: impl Into<String>) -> AnthropicConfig
models only.Set a custom base URL.
Sourcepub fn with_prompt_caching(self, enabled: bool) -> AnthropicConfig
Available on crate feature models only.
pub fn with_prompt_caching(self, enabled: bool) -> AnthropicConfig
models only.Enable or disable prompt caching.
Sourcepub fn with_thinking_mode(self, mode: ThinkingMode) -> AnthropicConfig
Available on crate feature models only.
pub fn with_thinking_mode(self, mode: ThinkingMode) -> AnthropicConfig
models only.Set the thinking mode.
Sourcepub fn with_thinking(self, budget_tokens: u32) -> AnthropicConfig
Available on crate feature models only.
pub fn with_thinking(self, budget_tokens: u32) -> AnthropicConfig
models only.Convenience: enable budget-based thinking with the given token budget.
Sourcepub fn with_effort(self, effort: Effort) -> AnthropicConfig
Available on crate feature models only.
pub fn with_effort(self, effort: Effort) -> AnthropicConfig
models only.Set the effort level (goes into output_config.effort).
Sourcepub fn with_fast_mode(self, enabled: bool) -> AnthropicConfig
Available on crate feature models only.
pub fn with_fast_mode(self, enabled: bool) -> AnthropicConfig
models only.Enable fast mode (Opus 4.6+ only, beta).
Sourcepub fn with_citations(self, enabled: bool) -> AnthropicConfig
Available on crate feature models only.
pub fn with_citations(self, enabled: bool) -> AnthropicConfig
models only.Enable citations on documents.
Sourcepub fn with_inference_geo(self, geo: impl Into<String>) -> AnthropicConfig
Available on crate feature models only.
pub fn with_inference_geo(self, geo: impl Into<String>) -> AnthropicConfig
models only.Set geographic routing for data residency.
Sourcepub fn with_service_tier(self, tier: impl Into<String>) -> AnthropicConfig
Available on crate feature models only.
pub fn with_service_tier(self, tier: impl Into<String>) -> AnthropicConfig
models only.Set the service tier.
Sourcepub fn with_context_management(self, cm: ContextManagement) -> AnthropicConfig
Available on crate feature models only.
pub fn with_context_management(self, cm: ContextManagement) -> AnthropicConfig
models only.Set context management (tool result clearing, thinking block clearing).
Sourcepub fn with_beta_feature(self, feature: impl Into<String>) -> AnthropicConfig
Available on crate feature models only.
pub fn with_beta_feature(self, feature: impl Into<String>) -> AnthropicConfig
models only.Add a beta feature header value.
Sourcepub fn with_api_version(self, version: impl Into<String>) -> AnthropicConfig
Available on crate feature models only.
pub fn with_api_version(self, version: impl Into<String>) -> AnthropicConfig
models only.Set a custom API version header.
Sourcepub fn with_tool_search(self, config: ToolSearchConfig) -> AnthropicConfig
Available on crate feature models only.
pub fn with_tool_search(self, config: ToolSearchConfig) -> AnthropicConfig
models only.Set tool search configuration for dynamic tool discovery.
When set, only tools whose names match the regex pattern are loaded per request. When not set, all available tools are loaded.
§Example
use adk_model::anthropic::AnthropicConfig;
use adk_anthropic::ToolSearchConfig;
let config = AnthropicConfig::new("sk-ant-xxx", "claude-sonnet-4-6")
.with_tool_search(ToolSearchConfig::new("^(search|fetch)_.*"));Trait Implementations§
Source§impl Clone for AnthropicConfig
impl Clone for AnthropicConfig
Source§fn clone(&self) -> AnthropicConfig
fn clone(&self) -> AnthropicConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more