Skip to main content

elph_ai/
lib.rs

1//! Unified LLM API with provider collections, automatic auth resolution, token and
2//! cost tracking, and session context hand-off between models.
3//!
4//! Ported from [@earendil-works/pi-ai](https://github.com/earendil-works/pi/tree/main/packages/ai).
5
6pub use anyhow::Result;
7
8pub mod api;
9pub mod auth;
10pub mod images;
11pub mod models;
12pub mod providers;
13pub mod types;
14pub mod utils;
15
16pub use api::codex_transport::{
17    CodexWebSocketDebugStats, close_codex_websocket_sessions, get_codex_websocket_debug_stats,
18    get_codex_websocket_input_delta, reset_codex_websocket_debug_stats,
19};
20pub use api::faux::FauxResponseStep;
21pub use auth::oauth::{
22    OAuthApiKeyResult, OAuthProviderInterface, OPENAI_CODEX_BROWSER_LOGIN_METHOD,
23    OPENAI_CODEX_DEVICE_CODE_LOGIN_METHOD, anthropic_oauth, builtin_oauth_provider_ids, get_oauth_api_key,
24    get_oauth_provider, get_oauth_providers, github_copilot_oauth, oauth_provider_modify_models, openai_codex_oauth,
25    refresh_oauth_token, register_oauth_provider, reset_oauth_providers, unregister_oauth_provider,
26};
27pub use auth::{
28    DefaultAuthContext, InMemoryCredentialStore, ModelsError, ModelsErrorCode, OAuthCredential, default_auth_context,
29    env_api_key_auth, resolve_provider_auth,
30};
31pub use images::{CreateImagesModelsOptions, ImagesModels, builtin_images_models, generate_images};
32pub use models::{
33    CreateModelsOptions, CreateProviderOptions, Models, MutableModels, Provider, calculate_cost, clamp_thinking_level,
34    create_models, create_provider, get_supported_thinking_levels, has_api, models_are_equal,
35};
36pub use providers::faux::{
37    FauxProviderHandle, faux_assistant_message, faux_provider, faux_text, faux_thinking, faux_tool_call,
38};
39pub use providers::{builtin_models, get_builtin_model, get_builtin_models, get_builtin_providers};
40pub use types::*;
41pub use utils::event_stream::EventStreamIterator;
42pub use utils::{overflow, retry, validation};