Skip to main content

vtcode_llm/provider/
provider_trait.rs

1use async_stream::try_stream;
2use async_trait::async_trait;
3use compact_str::format_compact;
4use rustc_hash::FxHashMap;
5use std::sync::LazyLock;
6use std::sync::RwLock;
7use vtcode_commons::llm::BackendKind;
8
9use vtcode_commons::tool_types::CompactStr;
10
11use super::{
12    LLMNormalizedStream, LLMRequest, LLMResponse, LLMStream, LLMStreamEvent, Message, NativeResponse, NativeStream,
13    ResponsesCompactionOptions, SamplingOverrides,
14};
15pub use vtcode_commons::llm::{LLMError, LLMErrorMetadata};
16
17/// Generic effort levels supported by providers that advertise configurable
18/// reasoning without exposing model-specific catalog metadata.
19pub(crate) const GENERIC_REASONING_EFFORTS: &[&str] = &["low", "medium", "high"];
20
21/// Return the catalog's effort metadata while preserving the distinction
22/// between an unknown route and a known route that only exposes structured
23/// reasoning. An empty catalog list is authoritative: it means the route does
24/// not accept a configurable effort payload.
25pub(crate) fn catalog_reasoning_efforts(provider: &str, model: &str) -> Option<&'static [&'static str]> {
26    vtcode_config::models::model_catalog_entry(provider, model).map(|entry| entry.reasoning_efforts)
27}
28
29/// Resolve the catalog's exact effort list while retaining the explicit
30/// generic contract for provider routes that advertise effort support without
31/// a built-in model entry (for example, an OpenAI-compatible custom endpoint).
32pub(crate) fn catalog_or_generic_reasoning_efforts(provider: &str, model: &str) -> &'static [&'static str] {
33    catalog_reasoning_efforts(provider, model).unwrap_or(GENERIC_REASONING_EFFORTS)
34}
35
36/// Resolve catalog levels while allowing an explicitly configured custom route
37/// to advertise the shared generic effort contract. Unsupported unknown routes
38/// remain empty so request builders fail closed.
39pub(crate) fn catalog_or_explicit_reasoning_efforts(
40    provider: &str,
41    model: &str,
42    explicitly_supported: bool,
43) -> &'static [&'static str] {
44    catalog_reasoning_efforts(provider, model)
45        .or_else(|| explicitly_supported.then_some(GENERIC_REASONING_EFFORTS))
46        .unwrap_or(&[])
47}
48
49/// Resolve a model's catalog context window with a provider-specific fallback.
50///
51/// Provider adapters use this helper instead of maintaining independent model
52/// name tables. Explicit provider overrides remain the caller's responsibility
53/// and are applied before this lookup.
54pub(crate) fn catalog_context_window(provider: &str, model: &str, fallback: usize) -> usize {
55    vtcode_config::models::model_catalog_entry(provider, model)
56        .map(|entry| entry.context_window)
57        .filter(|context_window| *context_window > 0)
58        .unwrap_or(fallback)
59}
60
61/// Cached provider capabilities to reduce repeated trait method calls
62#[derive(Debug, Clone)]
63pub struct ProviderCapabilities {
64    pub(crate) provider_name: String,
65    pub(crate) model: String,
66    pub streaming: bool,
67    pub reasoning: bool,
68    pub reasoning_effort: bool,
69    pub tools: bool,
70    pub parallel_tool_config: bool,
71    pub(crate) structured_output: bool,
72    pub(crate) context_caching: bool,
73    pub responses_compaction: bool,
74    pub context_edits: bool,
75    /// Whether the selected provider/model can carry Anthropic's native
76    /// turn-scoped system-message lifecycle field on the wire.
77    pub turn_scoped_system_messages: bool,
78    pub(crate) vision: bool,
79    pub(crate) context_size: usize,
80}
81
82impl ProviderCapabilities {
83    fn detect(provider: &dyn LLMProvider, model: &str) -> Self {
84        Self {
85            provider_name: provider.name().to_string(),
86            model: model.to_string(),
87            streaming: provider.supports_streaming(),
88            reasoning: provider.supports_reasoning(model),
89            reasoning_effort: !provider.supported_reasoning_efforts(model).is_empty(),
90            tools: provider.supports_tools(model),
91            parallel_tool_config: provider.supports_parallel_tool_config(model),
92            structured_output: provider.supports_structured_output(model),
93            context_caching: provider.supports_context_caching(model),
94            responses_compaction: provider.supports_responses_compaction(model),
95            context_edits: provider.supports_context_edits(model),
96            turn_scoped_system_messages: provider.supports_turn_scoped_system_messages(model),
97            vision: provider.supports_vision(model),
98            context_size: provider.effective_context_size(model),
99        }
100    }
101
102    pub(crate) fn has_advanced_features(&self) -> bool {
103        self.reasoning || self.structured_output || self.context_caching || self.reasoning_effort
104    }
105
106    pub(crate) fn summary(&self) -> String {
107        let mut features = Vec::new();
108
109        if self.streaming {
110            features.push("streaming");
111        }
112        if self.reasoning {
113            features.push("advanced-reasoning");
114        }
115        if self.reasoning_effort {
116            features.push("reasoning-effort");
117        }
118        if self.structured_output {
119            features.push("structured-output");
120        }
121        if self.context_caching {
122            features.push("context-caching");
123        }
124        if self.parallel_tool_config {
125            features.push("parallel-tools");
126        }
127        if self.responses_compaction {
128            features.push("responses-compaction");
129        }
130        if self.context_edits {
131            features.push("context-edits");
132        }
133
134        let features_str = if features.is_empty() {
135            "basic".to_string()
136        } else {
137            features.join(", ")
138        };
139
140        format!("{} ({} tokens): {}", self.model, self.context_size, features_str)
141    }
142}
143
144/// Global cache for provider capabilities (provider_name::model -> capabilities)
145static CAPABILITY_CACHE: LazyLock<RwLock<FxHashMap<CompactStr, ProviderCapabilities>>> =
146    LazyLock::new(|| RwLock::new(FxHashMap::default()));
147
148/// Extract and cache provider capabilities for a given provider and model
149pub fn get_cached_capabilities(provider: &dyn LLMProvider, model: &str) -> ProviderCapabilities {
150    let cache_key = format_compact!("{}::{}::{}", provider.name(), model, provider.effective_context_size(model));
151
152    // Check if already cached
153    if let Ok(cache) = CAPABILITY_CACHE.read()
154        && let Some(caps) = cache.get(&cache_key)
155    {
156        return caps.clone();
157    }
158
159    // Compute capabilities
160    let caps = ProviderCapabilities::detect(provider, model);
161
162    // Cache for future use
163    if let Ok(mut cache) = CAPABILITY_CACHE.write() {
164        cache.insert(cache_key, caps.clone());
165    }
166
167    caps
168}
169
170/// Universal LLM provider trait
171#[async_trait]
172pub trait LLMProvider: Send + Sync {
173    /// Provider name (e.g., "gemini", "openai", "anthropic")
174    fn name(&self) -> &str;
175
176    /// Whether this instance can use the direct API-key Decisions endpoint.
177    /// Capability checks must not discover credentials or dispatch requests.
178    fn supports_decisions(&self) -> bool {
179        false
180    }
181
182    /// Evaluate one text-only choice question. Unsupported providers do no I/O.
183    async fn decide_choice(
184        &self,
185        _request: super::ChoiceDecisionRequest,
186    ) -> Result<super::ChoiceDecisionResponse, LLMError> {
187        Err(LLMError::Provider {
188            message: "Decisions is unsupported for this provider".to_owned(),
189            metadata: None,
190        })
191    }
192
193    /// Whether this provider implements the bound computer-use route.
194    /// Capability checks must not discover credentials or dispatch requests.
195    fn supports_computer_use(&self) -> bool {
196        false
197    }
198
199    /// Run one request on the bound computer-use route. Only providers that
200    /// declare native tools implement this; the default reports unsupported
201    /// without I/O. Implementations verify the provider/protocol route
202    /// against the computer-use gate before sending anything; any model on a
203    /// declared route is admitted.
204    async fn generate_native(&self, _request: LLMRequest) -> Result<NativeResponse, LLMError> {
205        Err(LLMError::Provider {
206            message: "Computer use is unsupported for this provider".to_owned(),
207            metadata: None,
208        })
209    }
210
211    /// Stream one request on the bound computer-use route. Only providers
212    /// that declare native tools implement this; the default reports
213    /// unsupported without I/O. Implementations verify the target against
214    /// the computer-use gate before sending anything and complete with the
215    /// same [`NativeResponse`] the non-streaming route returns.
216    async fn stream_native(&self, _request: LLMRequest) -> Result<NativeStream, LLMError> {
217        Err(LLMError::Provider {
218            message: "Computer use is unsupported for this provider".to_owned(),
219            metadata: None,
220        })
221    }
222
223    /// The canonical backend kind for this provider.
224    ///
225    /// Defaults to matching on [`name()`](LLMProvider::name) against the
226    /// well-known provider names. Providers should override this when their
227    /// name does not match the canonical mapping (e.g., dynamic names).
228    fn backend_kind(&self) -> BackendKind {
229        match self.name() {
230            "gemini" => BackendKind::Gemini,
231            "openai" => BackendKind::OpenAI,
232            "anthropic" => BackendKind::Anthropic,
233            "deepseek" => BackendKind::DeepSeek,
234            "meta" => BackendKind::Meta,
235            "mistral" => BackendKind::Mistral,
236            "openrouter" => BackendKind::OpenRouter,
237            "ollama" => BackendKind::Ollama,
238            "llamacpp" => BackendKind::LlamaCpp,
239            "zai" => BackendKind::ZAI,
240            "moonshot" => BackendKind::Moonshot,
241            "huggingface" => BackendKind::HuggingFace,
242            "minimax" => BackendKind::Minimax,
243            "mimo" => BackendKind::MiMo,
244            "opencode-zen" => BackendKind::OpenCodeZen,
245            "opencode-go" => BackendKind::OpenCodeGo,
246            "qwen" => BackendKind::Qwen,
247            "stepfun" => BackendKind::StepFun,
248            "evolink" => BackendKind::Evolink,
249            "poolside" => BackendKind::Poolside,
250            "nvidia" => BackendKind::Nvidia,
251            "merge-gateway" => BackendKind::MergeGateway,
252            "vercel" => BackendKind::Vercel,
253            _ => BackendKind::OpenAI,
254        }
255    }
256
257    /// Whether the provider has native streaming support
258    fn supports_streaming(&self) -> bool {
259        false
260    }
261
262    /// Whether the provider can service non-streaming generation requests for the model.
263    fn supports_non_streaming(&self, _model: &str) -> bool {
264        true
265    }
266
267    /// Whether the provider surfaces structured reasoning traces for the given model
268    fn supports_reasoning(&self, _model: &str) -> bool {
269        false
270    }
271
272    /// Whether the provider accepts configurable reasoning effort for the model
273    fn supports_reasoning_effort(&self, _model: &str) -> bool {
274        false
275    }
276
277    /// Exact levels accepted by this route; providers may override catalog metadata.
278    fn supported_reasoning_efforts(&self, model: &str) -> &'static [&'static str] {
279        if !self.supports_reasoning_effort(model) {
280            return &[];
281        }
282        catalog_or_generic_reasoning_efforts(self.name(), model)
283    }
284
285    /// Provider/model-specific sampling parameter overrides.
286    ///
287    /// Custom-provider profiles may pin exact sampling values per model; every
288    /// field defaults to `None`, meaning the agent loop's global config value
289    /// applies unchanged.
290    fn sampling_overrides(&self, _model: &str) -> SamplingOverrides {
291        SamplingOverrides::default()
292    }
293
294    /// Whether the provider supports structured tool calling for the given model
295    fn supports_tools(&self, _model: &str) -> bool {
296        true
297    }
298
299    /// Whether the provider understands parallel tool configuration payloads
300    fn supports_parallel_tool_config(&self, _model: &str) -> bool {
301        false
302    }
303
304    /// Whether the provider supports structured output (JSON schema guarantees)
305    fn supports_structured_output(&self, _model: &str) -> bool {
306        false
307    }
308
309    /// Whether the provider supports prompt/context caching
310    fn supports_context_caching(&self, _model: &str) -> bool {
311        false
312    }
313
314    /// Effective requested Responses cache lifetime, when cache options are emitted.
315    fn requested_prompt_cache_ttl(&self, _model: &str) -> Option<vtcode_config::core::prompt_cache::PromptCacheTtl> {
316        None
317    }
318
319    /// Whether the provider supports vision (image analysis) for given model
320    fn supports_vision(&self, _model: &str) -> bool {
321        false
322    }
323
324    /// Whether the provider supports Responses API server-side compaction.
325    fn supports_responses_compaction(&self, _model: &str) -> bool {
326        false
327    }
328
329    /// Whether the request path can enforce a provider-native `allowed_tools` subset.
330    fn supports_native_allowed_tools(&self, _model: &str) -> bool {
331        false
332    }
333
334    /// Whether the provider supports provider-native context editing such as
335    /// tool-result clearing.
336    fn supports_context_edits(&self, _model: &str) -> bool {
337        false
338    }
339
340    /// Whether the selected provider/model can carry Anthropic's native
341    /// turn-scoped system-message lifecycle field on the wire.
342    ///
343    /// This is intentionally narrower than [`Self::supports_context_edits`]: a
344    /// provider can expose Anthropic-shaped requests without supporting the
345    /// `clear_at` field, and a provider name does not necessarily identify the
346    /// wire protocol for every model. The runtime keeps the typed marker in
347    /// canonical history either way, translating it to an ordinary system or
348    /// history directive when this capability is false.
349    fn supports_turn_scoped_system_messages(&self, _model: &str) -> bool {
350        false
351    }
352
353    /// Whether the provider supports the interactive manual `/compact` command path.
354    ///
355    /// This is narrower than general Responses compaction support and may exclude
356    /// compatible endpoints that do not match VT Code's native OpenAI UX contract.
357    fn supports_manual_openai_compaction(&self, _model: &str) -> bool {
358        false
359    }
360
361    /// Whether the provider supports threshold-triggered inline compaction via
362    /// request fields (Anthropic `compact_20260112`).
363    ///
364    /// This is distinct from [`supports_responses_compaction`](LLMProvider::supports_responses_compaction),
365    /// which is overloaded: OpenAI-compatible endpoints report it for their
366    /// standalone `/responses/compact` endpoint while Anthropic reports it for
367    /// inline compaction. Only the latter can be driven through `generate` with a
368    /// `compact_20260112` context-management edit, so the unified compaction
369    /// dispatch uses this method (not the overloaded flag) to pick the
370    /// `NativeInline` strategy and avoid sending an Anthropic-specific payload to
371    /// an OpenAI-compatible endpoint (which would only be rejected and fall back
372    /// to local summarization anyway).
373    fn supports_native_inline_compaction(&self, _model: &str) -> bool {
374        false
375    }
376
377    /// Explain why the `--native-only` manual `/compact` path is unavailable.
378    ///
379    /// This message only surfaces when the user explicitly passes `--native-only`
380    /// and the provider does not expose a native server-side compaction endpoint.
381    /// The plain `/compact` command is provider-agnostic and always falls back to
382    /// local summarization, so it is never refused on capability grounds.
383    fn manual_openai_compaction_unavailable_message(&self, model: &str) -> String {
384        format!(
385            "`--native-only` `/compact` requires a provider that exposes a native server-side compaction endpoint, which this provider does not. Active provider/model: {} / {}. Run `/compact` without `--native-only` to compact via the universal local summarization fallback.",
386            self.name(),
387            model,
388        )
389    }
390
391    /// Get the effective context window size for a model.
392    ///
393    /// Curated catalog capacity is the default for providers that do not have
394    /// a narrower route-specific limit. Adapters with an explicit endpoint
395    /// ceiling can still override this method and keep that ceiling intact.
396    fn effective_context_size(&self, model: &str) -> usize {
397        catalog_context_window(self.name(), model, 128_000)
398    }
399
400    /// Compact conversation history using provider-native Responses `/compact`
401    /// support when available.
402    async fn compact_history(&self, _model: &str, _history: &[Message]) -> Result<Vec<Message>, LLMError> {
403        Err(LLMError::Provider {
404            message: "Conversation compaction is not supported by this provider".to_string(),
405            metadata: None,
406        })
407    }
408
409    /// Compact conversation history with standalone Responses compaction options.
410    async fn compact_history_with_options(
411        &self,
412        _model: &str,
413        _history: &[Message],
414        _options: &ResponsesCompactionOptions,
415    ) -> Result<Vec<Message>, LLMError> {
416        Err(LLMError::Provider {
417            message: "manual OpenAI compaction is not supported by this provider".to_string(),
418            metadata: None,
419        })
420    }
421
422    /// Generate completion
423    async fn generate(&self, request: LLMRequest) -> Result<LLMResponse, LLMError>;
424
425    /// Generate an independent auxiliary result without replacing the primary
426    /// conversation's transport state. Stateless providers can use `generate`.
427    async fn generate_auxiliary(&self, request: LLMRequest) -> Result<LLMResponse, LLMError> {
428        self.generate(request).await
429    }
430
431    /// Stream completion (optional)
432    async fn stream(&self, request: LLMRequest) -> Result<LLMStream, LLMError> {
433        // Default implementation falls back to non-streaming
434        let response = self.generate(request).await?;
435        let stream = try_stream! {
436            yield LLMStreamEvent::Completed { response: Box::new(response) };
437        };
438        Ok(Box::pin(stream))
439    }
440
441    /// Normalized streaming contract layered on top of the legacy provider stream.
442    async fn stream_normalized(&self, request: LLMRequest) -> Result<LLMNormalizedStream, LLMError> {
443        let mut legacy_stream = self.stream(request).await?;
444        let stream = try_stream! {
445            while let Some(event) = futures::StreamExt::next(&mut legacy_stream).await {
446                for normalized in event?.into_normalized() {
447                    yield normalized;
448                }
449            }
450        };
451        Ok(Box::pin(stream))
452    }
453
454    /// Provider-specific streaming path that can service interactive runtime
455    /// requests while the stream is active. Copilot uses this to bridge ACP
456    /// tool calls and permission prompts back into VT Code's turn runtime.
457    #[cfg(feature = "copilot")]
458    fn start_copilot_prompt_session<'a>(
459        &'a self,
460        _request: LLMRequest,
461        _tools: &'a [super::ToolDefinition],
462    ) -> Option<crate::copilot::CopilotPromptSessionFuture<'a>> {
463        None
464    }
465
466    /// Get supported models
467    fn supported_models(&self) -> Vec<String>;
468
469    /// Fetch account balance for this provider, if supported.
470    async fn get_balance(&self) -> Result<Option<vtcode_commons::llm::BalanceInfo>, LLMError> {
471        Ok(None)
472    }
473
474    /// Validate request for this provider
475    fn validate_request(&self, request: &LLMRequest) -> Result<(), LLMError>;
476}
477
478/// Provider-local context capacity discovered for the selected model.
479/// All transport and capability behavior remains delegated to the underlying provider.
480///
481/// The `Box<dyn LLMProvider>` layer here is intentional: unlike
482/// `LlamaCppProvider`/`LmStudioProvider` (which always wrap `OpenAIProvider`
483/// and therefore store it concretely), the wrapped provider behind this type
484/// is selected at runtime and genuinely heterogeneous, so dynamic dispatch is
485/// required. `wrap` passes the box through untouched when no override applies,
486/// avoiding a second vtable layer.
487pub struct ContextWindowProvider {
488    inner: Box<dyn LLMProvider>,
489    model: CompactStr,
490    context_window: usize,
491}
492
493impl ContextWindowProvider {
494    /// Unknown/zero metadata preserves the backend's usable capacity.
495    pub fn wrap(inner: Box<dyn LLMProvider>, model: &str, context_window: Option<usize>) -> Box<dyn LLMProvider> {
496        match context_window.filter(|value| *value > 0) {
497            Some(context_window) => Box::new(Self { inner, model: model.into(), context_window }),
498            None => inner,
499        }
500    }
501}
502
503#[async_trait]
504impl LLMProvider for ContextWindowProvider {
505    fn name(&self) -> &str {
506        self.inner.name()
507    }
508
509    fn supports_decisions(&self) -> bool {
510        self.inner.supports_decisions()
511    }
512
513    async fn decide_choice(
514        &self,
515        request: super::ChoiceDecisionRequest,
516    ) -> Result<super::ChoiceDecisionResponse, LLMError> {
517        self.inner.decide_choice(request).await
518    }
519
520    fn backend_kind(&self) -> BackendKind {
521        self.inner.backend_kind()
522    }
523
524    fn supports_streaming(&self) -> bool {
525        self.inner.supports_streaming()
526    }
527
528    fn supports_non_streaming(&self, model: &str) -> bool {
529        self.inner.supports_non_streaming(model)
530    }
531
532    fn supports_reasoning(&self, model: &str) -> bool {
533        self.inner.supports_reasoning(model)
534    }
535
536    fn supports_reasoning_effort(&self, model: &str) -> bool {
537        self.inner.supports_reasoning_effort(model)
538    }
539
540    fn supported_reasoning_efforts(&self, model: &str) -> &'static [&'static str] {
541        self.inner.supported_reasoning_efforts(model)
542    }
543
544    fn sampling_overrides(&self, model: &str) -> SamplingOverrides {
545        self.inner.sampling_overrides(model)
546    }
547
548    fn supports_tools(&self, model: &str) -> bool {
549        self.inner.supports_tools(model)
550    }
551
552    fn supports_parallel_tool_config(&self, model: &str) -> bool {
553        self.inner.supports_parallel_tool_config(model)
554    }
555
556    fn supports_structured_output(&self, model: &str) -> bool {
557        self.inner.supports_structured_output(model)
558    }
559
560    fn supports_context_caching(&self, model: &str) -> bool {
561        self.inner.supports_context_caching(model)
562    }
563
564    fn requested_prompt_cache_ttl(&self, model: &str) -> Option<vtcode_config::core::prompt_cache::PromptCacheTtl> {
565        self.inner.requested_prompt_cache_ttl(model)
566    }
567
568    fn supports_vision(&self, model: &str) -> bool {
569        self.inner.supports_vision(model)
570    }
571
572    fn supports_responses_compaction(&self, model: &str) -> bool {
573        self.inner.supports_responses_compaction(model)
574    }
575
576    fn supports_native_allowed_tools(&self, model: &str) -> bool {
577        self.inner.supports_native_allowed_tools(model)
578    }
579
580    fn supports_context_edits(&self, model: &str) -> bool {
581        self.inner.supports_context_edits(model)
582    }
583
584    fn supports_turn_scoped_system_messages(&self, model: &str) -> bool {
585        self.inner.supports_turn_scoped_system_messages(model)
586    }
587
588    fn supports_manual_openai_compaction(&self, model: &str) -> bool {
589        self.inner.supports_manual_openai_compaction(model)
590    }
591
592    fn supports_native_inline_compaction(&self, model: &str) -> bool {
593        self.inner.supports_native_inline_compaction(model)
594    }
595
596    fn manual_openai_compaction_unavailable_message(&self, model: &str) -> String {
597        self.inner.manual_openai_compaction_unavailable_message(model)
598    }
599
600    fn effective_context_size(&self, model: &str) -> usize {
601        let requested_model = if model.trim().is_empty() {
602            self.model.as_str()
603        } else {
604            model
605        };
606        if requested_model == self.model.as_str() {
607            self.context_window
608        } else {
609            self.inner.effective_context_size(requested_model)
610        }
611    }
612
613    async fn compact_history(&self, model: &str, history: &[Message]) -> Result<Vec<Message>, LLMError> {
614        self.inner.compact_history(model, history).await
615    }
616
617    async fn compact_history_with_options(
618        &self,
619        model: &str,
620        history: &[Message],
621        options: &ResponsesCompactionOptions,
622    ) -> Result<Vec<Message>, LLMError> {
623        self.inner.compact_history_with_options(model, history, options).await
624    }
625
626    async fn generate(&self, request: LLMRequest) -> Result<LLMResponse, LLMError> {
627        self.inner.generate(request).await
628    }
629
630    async fn generate_auxiliary(&self, request: LLMRequest) -> Result<LLMResponse, LLMError> {
631        self.inner.generate_auxiliary(request).await
632    }
633
634    async fn stream(&self, request: LLMRequest) -> Result<LLMStream, LLMError> {
635        self.inner.stream(request).await
636    }
637
638    async fn stream_normalized(&self, request: LLMRequest) -> Result<LLMNormalizedStream, LLMError> {
639        self.inner.stream_normalized(request).await
640    }
641
642    #[cfg(feature = "copilot")]
643    fn start_copilot_prompt_session<'a>(
644        &'a self,
645        request: LLMRequest,
646        tools: &'a [super::ToolDefinition],
647    ) -> Option<crate::copilot::CopilotPromptSessionFuture<'a>> {
648        self.inner.start_copilot_prompt_session(request, tools)
649    }
650
651    fn supported_models(&self) -> Vec<String> {
652        self.inner.supported_models()
653    }
654
655    async fn get_balance(&self) -> Result<Option<vtcode_commons::llm::BalanceInfo>, LLMError> {
656        self.inner.get_balance().await
657    }
658
659    fn validate_request(&self, request: &LLMRequest) -> Result<(), LLMError> {
660        self.inner.validate_request(request)
661    }
662}