siumai_openai_compatible/lib.rs
1//! Reusable OpenAI-compatible provider runtime for Siumai.
2//!
3//! This crate composes `siumai-protocol-openai` and `siumai-transport` into a configurable
4//! execution engine. It owns explicit generic/custom provider construction and a bounded,
5//! versioned codec seam. Branded provider crates own their profiles, options, evidence, and model
6//! advisories while reusing this engine for protocol execution.
7#![deny(unsafe_code)]
8
9mod configured;
10
11pub use configured::{
12 BearerCredential, CredentialRequest, CredentialSourceError, DynamicCredentialSource,
13 OpenAiCompatibleApiMode, OpenAiCompatibleConfigError, OpenAiCompatibleCredential,
14 OpenAiCompatibleLanguageModel, OpenAiCompatibleProfile, OpenAiCompatibleProvider,
15 OpenAiCompatibleProviderBuilder, ResponsesWireDialect,
16};
17
18/// Versioned, provider-neutral composition hooks for branded provider crates.
19///
20/// These hooks may shape and decode protocol payloads, but they cannot replace endpoint,
21/// authentication, transport, retry, identity, or stream lifecycle policy. Application code
22/// should use a branded provider crate or the configured compatible provider instead.
23pub mod extension {
24 /// First version of the bounded compatible-provider composition contract.
25 pub mod v1 {
26 pub use crate::configured::{
27 ChatCodecPolicy, CompatibleStreamDecoder, PreparedChatCall, PreparedResponsesCall,
28 ResponsesCodecPolicy,
29 };
30 }
31
32 /// Stateless OpenAI-family HTTP and SSE execution contract for provider authors.
33 ///
34 /// This API is covered by semver for direct users of `siumai-openai-compatible`. It accepts
35 /// provider-prepared relative targets, JSON bodies, non-credential headers, replay proof,
36 /// warnings, sanitized diagnostics context, and provider-owned decoders. It cannot construct
37 /// providers or alter endpoint, credentials, signing, retry policy, timeout, admission, or
38 /// transport limits.
39 ///
40 /// Direct setup failures are returned by [`crate::extension::v2::execute_direct`]. SSE setup
41 /// failures are returned by [`crate::extension::v2::execute_sse`]; after establishment,
42 /// [`crate::extension::v2::SseStream`] emits decoded events or one final error and then EOF.
43 /// Dropping the stream cancels only its child operation.
44 pub mod v2 {
45 pub use crate::configured::execution::{
46 DirectDecoder, DirectResponse, ExecutionContext, PreparedCall, PreparedJsonBody,
47 SseStream, SseStreamDecoder, StreamResponseContext, execute_direct, execute_sse,
48 };
49 }
50}