Skip to main content

AnthropicProvider

Struct AnthropicProvider 

Source
pub struct AnthropicProvider { /* private fields */ }

Implementations§

Source§

impl AnthropicProvider

Source

pub fn new(api_key: String) -> Self

Source

pub fn from_config( api_key: Option<String>, model: Option<String>, base_url: Option<String>, prompt_cache: Option<PromptCachingConfig>, timeouts: Option<TimeoutsConfig>, anthropic_config: Option<AnthropicConfig>, model_behavior: Option<ModelConfig>, ) -> Self

Source

pub fn with_leak_protection( &self, request: LLMRequest, secret_description: &str, ) -> LLMRequest

Prepends a non-disclosure reminder to the system prompt. No supported Claude model accepts an assistant-message prefill, so the system prompt is the only valid place for this instruction.

Source

pub fn format_documents_xml(&self, documents: Vec<(&str, &str)>) -> String

Source

pub fn extract_xml_block(&self, content: &str, tag: &str) -> Option<String>

Trait Implementations§

Source§

impl Clone for AnthropicProvider

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl LLMClient for AnthropicProvider

Source§

fn generate<'life0, 'life1, 'async_trait>( &'life0 mut self, prompt: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<LLMResponse, LLMError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn model_id(&self) -> &str

Source§

impl LLMProvider for AnthropicProvider

Source§

fn name(&self) -> &str

Provider name (e.g., “gemini”, “openai”, “anthropic”)
Source§

fn supports_streaming(&self) -> bool

Whether the provider has native streaming support
Source§

fn supports_non_streaming(&self, _model: &str) -> bool

Whether the provider can service non-streaming generation requests for the model.
Source§

fn supports_reasoning(&self, model: &str) -> bool

Whether the provider surfaces structured reasoning traces for the given model
Source§

fn supported_reasoning_efforts(&self, model: &str) -> &'static [&'static str]

Exact levels accepted by this route; providers may override catalog metadata.
Source§

fn supports_reasoning_effort(&self, model: &str) -> bool

Whether the provider accepts configurable reasoning effort for the model
Source§

fn supports_parallel_tool_config(&self, model: &str) -> bool

Whether the provider understands parallel tool configuration payloads
Source§

fn supports_context_edits(&self, _model: &str) -> bool

Whether the provider supports provider-native context editing such as tool-result clearing.
Source§

fn supports_turn_scoped_system_messages(&self, model: &str) -> bool

Whether the selected provider/model can carry Anthropic’s native turn-scoped system-message lifecycle field on the wire. Read more
Source§

fn supports_responses_compaction(&self, model: &str) -> bool

Whether the provider supports Responses API server-side compaction.
Source§

fn supports_native_inline_compaction(&self, model: &str) -> bool

Whether the provider supports threshold-triggered inline compaction via request fields (Anthropic compact_20260112). Read more
Source§

fn effective_context_size(&self, model: &str) -> usize

Get the effective context window size for a model. Read more
Source§

fn supports_structured_output(&self, model: &str) -> bool

Whether the provider supports structured output (JSON schema guarantees)
Source§

fn supports_vision(&self, model: &str) -> bool

Whether the provider supports vision (image analysis) for given model
Source§

fn generate<'life0, 'async_trait>( &'life0 self, request: LLMRequest, ) -> Pin<Box<dyn Future<Output = Result<LLMResponse, LLMError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Generate completion
Source§

fn stream<'life0, 'async_trait>( &'life0 self, request: LLMRequest, ) -> Pin<Box<dyn Future<Output = Result<LLMStream, LLMError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stream completion (optional)
Source§

fn supported_models(&self) -> Vec<String>

Get supported models
Source§

fn validate_request(&self, request: &LLMRequest) -> Result<(), LLMError>

Validate request for this provider
Source§

fn supports_decisions(&self) -> bool

Whether this instance can use the direct API-key Decisions endpoint. Capability checks must not discover credentials or dispatch requests.
Source§

fn decide_choice<'life0, 'async_trait>( &'life0 self, _request: ChoiceDecisionRequest, ) -> Pin<Box<dyn Future<Output = Result<ChoiceDecisionResponse, LLMError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Evaluate one text-only choice question. Unsupported providers do no I/O.
Source§

fn backend_kind(&self) -> BackendKind

The canonical backend kind for this provider. Read more
Source§

fn sampling_overrides(&self, _model: &str) -> SamplingOverrides

Provider/model-specific sampling parameter overrides. Read more
Source§

fn supports_tools(&self, _model: &str) -> bool

Whether the provider supports structured tool calling for the given model
Source§

fn supports_context_caching(&self, _model: &str) -> bool

Whether the provider supports prompt/context caching
Source§

fn supports_native_allowed_tools(&self, _model: &str) -> bool

Whether the request path can enforce a provider-native allowed_tools subset.
Source§

fn supports_manual_openai_compaction(&self, _model: &str) -> bool

Whether the provider supports the interactive manual /compact command path. Read more
Source§

fn manual_openai_compaction_unavailable_message(&self, model: &str) -> String

Explain why the --native-only manual /compact path is unavailable. Read more
Source§

fn compact_history<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _model: &'life1 str, _history: &'life2 [Message], ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, LLMError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Compact conversation history using provider-native Responses /compact support when available.
Source§

fn compact_history_with_options<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, _model: &'life1 str, _history: &'life2 [Message], _options: &'life3 ResponsesCompactionOptions, ) -> Pin<Box<dyn Future<Output = Result<Vec<Message>, LLMError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Compact conversation history with standalone Responses compaction options.
Source§

fn stream_normalized<'life0, 'async_trait>( &'life0 self, request: LLMRequest, ) -> Pin<Box<dyn Future<Output = Result<LLMNormalizedStream, LLMError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Normalized streaming contract layered on top of the legacy provider stream.
Source§

fn start_copilot_prompt_session<'a>( &'a self, _request: LLMRequest, _tools: &'a [ToolDefinition], ) -> Option<CopilotPromptSessionFuture<'a>>

Provider-specific streaming path that can service interactive runtime requests while the stream is active. Copilot uses this to bridge ACP tool calls and permission prompts back into VT Code’s turn runtime.
Source§

fn get_balance<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<BalanceInfo>, LLMError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch account balance for this provider, if supported.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more