mod bodies;
mod catalog;
mod codex;
mod compatible;
mod headers;
#[cfg(test)]
mod tests;
pub use codex::OpenAiCodexProvider;
pub(crate) use codex::{CodexRefreshedAuth, codex_account_id_for, normalize_codex_model};
pub use compatible::OpenAiCompatibleProvider;
pub(crate) use bodies::response_instructions;
#[cfg(test)]
pub(crate) use bodies::{
build_chat_completion_tools_json, chat_completion_tools_json, codex_responses_body,
openai_compatible_chat_completions_body,
};
pub(crate) use catalog::fetch_model_catalog_response_text_cancellable;
#[cfg(test)]
pub(crate) use catalog::{
extract_chatgpt_account_id, parse_codex_model_catalog_response,
parse_openai_compatible_model_catalog_response,
};
pub(crate) use headers::{codex_sse_headers_with_routing_hint, package_user_agent};
use crate::{
cancellation::AgentCancellation,
providers::{ProviderEvent, ProviderRequest},
};
pub(crate) const CODEX_MODEL_CATALOG_CLIENT_VERSION: &str = "0.153.2";
pub trait Provider: Send + Sync {
#[cfg(test)]
fn service_tier_for_test(&self) -> Option<&str> {
None
}
fn requested_service_tier(&self) -> Option<&str> {
None
}
#[cfg(test)]
fn stream(
&self,
request: ProviderRequest,
on_event: &mut dyn FnMut(ProviderEvent) -> anyhow::Result<()>,
) -> anyhow::Result<()> {
self.stream_cancellable(request, &AgentCancellation::default(), on_event)
}
fn stream_cancellable(
&self,
request: ProviderRequest,
cancellation: &AgentCancellation,
on_event: &mut dyn FnMut(ProviderEvent) -> anyhow::Result<()>,
) -> anyhow::Result<()>;
}