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§
Sourcefn 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 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
Sourcefn supported_models(&self) -> Vec<String>
fn supported_models(&self) -> Vec<String>
Get supported models
Sourcefn validate_request(&self, request: &LLMRequest) -> Result<(), LLMError>
fn validate_request(&self, request: &LLMRequest) -> Result<(), LLMError>
Validate request for this provider
Provided Methods§
Sourcefn backend_kind(&self) -> BackendKind
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).
Sourcefn supports_streaming(&self) -> bool
fn supports_streaming(&self) -> bool
Whether the provider has native streaming support
Sourcefn supports_non_streaming(&self, _model: &str) -> bool
fn supports_non_streaming(&self, _model: &str) -> bool
Whether the provider can service non-streaming generation requests for the model.
Sourcefn supports_reasoning(&self, _model: &str) -> bool
fn supports_reasoning(&self, _model: &str) -> bool
Whether the provider surfaces structured reasoning traces for the given model
Sourcefn supports_reasoning_effort(&self, _model: &str) -> bool
fn supports_reasoning_effort(&self, _model: &str) -> bool
Whether the provider accepts configurable reasoning effort for the model
Sourcefn supports_tools(&self, _model: &str) -> bool
fn supports_tools(&self, _model: &str) -> bool
Whether the provider supports structured tool calling for the given model
Sourcefn supports_parallel_tool_config(&self, _model: &str) -> bool
fn supports_parallel_tool_config(&self, _model: &str) -> bool
Whether the provider understands parallel tool configuration payloads
Sourcefn supports_structured_output(&self, _model: &str) -> bool
fn supports_structured_output(&self, _model: &str) -> bool
Whether the provider supports structured output (JSON schema guarantees)
Sourcefn supports_context_caching(&self, _model: &str) -> bool
fn supports_context_caching(&self, _model: &str) -> bool
Whether the provider supports prompt/context caching
Sourcefn supports_vision(&self, _model: &str) -> bool
fn supports_vision(&self, _model: &str) -> bool
Whether the provider supports vision (image analysis) for given model
Sourcefn supports_responses_compaction(&self, _model: &str) -> bool
fn supports_responses_compaction(&self, _model: &str) -> bool
Whether the provider supports Responses API server-side compaction.
Sourcefn supports_context_edits(&self, _model: &str) -> bool
fn supports_context_edits(&self, _model: &str) -> bool
Whether the provider supports provider-native context editing such as tool-result clearing.
Sourcefn supports_manual_openai_compaction(&self, _model: &str) -> bool
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.
Explain why the interactive manual /compact command path is unavailable.
Sourcefn effective_context_size(&self, _model: &str) -> usize
fn effective_context_size(&self, _model: &str) -> usize
Get the effective context window size for a model
Sourcefn 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<'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.
Sourcefn 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 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.
Sourcefn 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<'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)
Sourcefn 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 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.
Sourcefn start_copilot_prompt_session<'a>(
&'a self,
_request: LLMRequest,
_tools: &'a [ToolDefinition],
) -> Option<CopilotPromptSessionFuture<'a>>
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.
Sourcefn 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,
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".