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-5", "claude-sonnet-5").
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 for Claude Opus 5 or Claude Opus 4.8 (research preview). Delivers up to 2.5× higher output tokens/sec at premium 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 for Claude Opus 5 or Claude Opus 4.8.
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 moreSource§impl Debug for AnthropicConfig
impl Debug for AnthropicConfig
Source§impl Default for AnthropicConfig
impl Default for AnthropicConfig
Source§fn default() -> AnthropicConfig
fn default() -> AnthropicConfig
Source§impl<'de> Deserialize<'de> for AnthropicConfig
impl<'de> Deserialize<'de> for AnthropicConfig
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<AnthropicConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<AnthropicConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for AnthropicConfig
impl Serialize for AnthropicConfig
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for AnthropicConfig
impl RefUnwindSafe for AnthropicConfig
impl Send for AnthropicConfig
impl Sync for AnthropicConfig
impl Unpin for AnthropicConfig
impl UnsafeUnpin for AnthropicConfig
impl UnwindSafe for AnthropicConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.