agent_sdk_providers/lib.rs
1//! LLM provider trait, streaming primitives, and first-party provider implementations.
2//!
3//! This crate defines the [`LlmProvider`] trait that all LLM backends implement,
4//! streaming types for incremental response processing, attachment validation,
5//! model capability metadata, and seven first-party provider implementations.
6//!
7//! # Provider Implementations
8//!
9//! | Provider | Module | Protocol |
10//! |----------|--------|----------|
11//! | Anthropic (Messages API) | [`impls::anthropic`] | SSE streaming |
12//! | OpenAI (Chat Completions) | [`impls::openai`] | SSE streaming |
13//! | OpenAI (Responses API) | [`impls::openai_responses`] | SSE streaming |
14//! | OpenAI Codex / ChatGPT | [`impls::openai_codex_responses`] | WebSocket |
15//! | Google Gemini | [`impls::gemini`] | SSE streaming |
16//! | Google Vertex AI | [`impls::vertex`] | SSE streaming |
17//! | Cloudflare AI Gateway | [`impls::cloudflare_ai_gateway`] | Proxy wrapper |
18
19#![forbid(unsafe_code)]
20
21// The attachment-validation helpers are only ever called from a provider
22// impl (each gated behind its provider feature), so the whole module is dead
23// code when no provider is compiled in. Gate it on "any provider feature" to
24// keep `--no-default-features` builds warning- (and `-D warnings`-) clean.
25#[cfg(any(
26 feature = "anthropic",
27 feature = "openai",
28 feature = "openai-codex",
29 feature = "gemini",
30 feature = "vertex",
31 feature = "cloudflare",
32))]
33pub mod attachments;
34pub mod impls;
35pub mod model_capabilities;
36pub mod provider;
37pub mod refresh;
38pub mod router;
39pub mod search;
40pub mod streaming;
41pub mod structured;
42
43// Convenience re-exports — provider trait and streaming
44pub use provider::{LlmProvider, StructuredOutputSupport, collect_stream};
45pub use refresh::{RefreshingProvider, is_unauthorized_error};
46pub use router::{ModelRouter, ModelTier, TaskComplexity};
47pub use streaming::{StreamAccumulator, StreamBox, StreamDelta};
48pub use structured::{StructuredConfig, StructuredOutput, StructuredOutputError, run_structured};
49
50// Re-export all core LLM types so consumers can `use agent_sdk_providers::*`
51pub use agent_sdk_foundation::llm::*;
52
53// Provider re-exports — each is gated behind its provider feature.
54#[cfg(feature = "cloudflare")]
55pub use impls::CloudflareAIGatewayProvider;
56#[cfg(feature = "gemini")]
57pub use impls::GeminiProvider;
58#[cfg(feature = "openai-codex")]
59pub use impls::OpenAICodexResponsesProvider;
60#[cfg(feature = "vertex")]
61pub use impls::VertexProvider;
62#[cfg(feature = "anthropic")]
63pub use impls::{AnthropicProvider, is_oauth_token};
64#[cfg(feature = "openai")]
65pub use impls::{OpenAIProvider, OpenAIResponsesProvider};
66
67// Model capabilities
68pub use model_capabilities::{
69 ModelCapabilities, PricePoint, Pricing, SourceStatus, get_model_capabilities,
70 supported_model_capabilities,
71};
72
73// Search provider
74pub use search::{BraveSearchProvider, SearchProvider, SearchResponse, SearchResult};