Skip to main content

LLMProvider

Trait LLMProvider 

Source
pub trait LLMProvider: Send + Sync {
Show 25 methods // Required methods fn name(&self) -> &str; 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; fn supported_models(&self) -> Vec<String>; fn validate_request(&self, request: &LLMRequest) -> Result<(), LLMError>; // Provided methods fn backend_kind(&self) -> BackendKind { ... } fn supports_streaming(&self) -> bool { ... } fn supports_non_streaming(&self, _model: &str) -> bool { ... } fn supports_reasoning(&self, _model: &str) -> bool { ... } fn supports_reasoning_effort(&self, _model: &str) -> bool { ... } fn supports_tools(&self, _model: &str) -> bool { ... } fn supports_parallel_tool_config(&self, _model: &str) -> bool { ... } fn supports_structured_output(&self, _model: &str) -> bool { ... } fn supports_context_caching(&self, _model: &str) -> bool { ... } fn supports_vision(&self, _model: &str) -> bool { ... } fn supports_responses_compaction(&self, _model: &str) -> bool { ... } fn supports_context_edits(&self, _model: &str) -> bool { ... } fn supports_manual_openai_compaction(&self, _model: &str) -> bool { ... } fn manual_openai_compaction_unavailable_message( &self, model: &str, ) -> String { ... } fn effective_context_size(&self, _model: &str) -> usize { ... } 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 { ... } 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 { ... } 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 { ... } 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 { ... } fn start_copilot_prompt_session<'a>( &'a self, _request: LLMRequest, _tools: &'a [ToolDefinition], ) -> Option<CopilotPromptSessionFuture<'a>> { ... } 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 { ... }
}
Expand description

Universal LLM provider trait

Required Methods§

Source

fn name(&self) -> &str

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

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 supported_models(&self) -> Vec<String>

Get supported models

Source

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

Validate request for this provider

Provided Methods§

Source

fn backend_kind(&self) -> BackendKind

The canonical backend kind for this provider.

Defaults to matching on name() against the well-known provider names. Providers should override this when their name does not match the canonical mapping (e.g., dynamic names).

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 supports_reasoning_effort(&self, _model: &str) -> bool

Whether the provider accepts configurable reasoning effort for the model

Source

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

Whether the provider supports structured tool calling for the given model

Source

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

Whether the provider understands parallel tool configuration payloads

Source

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

Whether the provider supports structured output (JSON schema guarantees)

Source

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

Whether the provider supports prompt/context caching

Source

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

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

Source

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

Whether the provider supports Responses API server-side compaction.

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_manual_openai_compaction(&self, _model: &str) -> bool

Whether the provider supports the interactive manual /compact command path.

This is narrower than general Responses compaction support and may exclude compatible endpoints that do not match VT Code’s native OpenAI UX contract.

Source

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

Explain why the interactive manual /compact command path is unavailable.

Source

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

Get the effective context window size for a model

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<'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 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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§