grain_llm_genai/lib.rs
1//! `grain-llm-genai` — genai-backed [`grain_agent_core::LlmStream`] implementation.
2//!
3//! Bridges the transport-agnostic agent loop in `grain-agent-core` to the
4//! [`genai`] crate's multi-provider chat API.
5//!
6//! - [`mapping::outbound`] — `LlmContext` → `genai::chat::ChatRequest`,
7//! including Anthropic-style signed-thinking replay.
8//! - [`mapping::inbound`] — `genai::chat::ChatStreamEvent` →
9//! `AssistantMessageEvent` via the [`InboundState`] state machine.
10//! - [`stream`] — `GenaiStream`, the [`LlmStream`] implementation.
11//! - [`builder`] — `GenaiStreamBuilder`: env-var API-key resolver, OpenAI-compat
12//! endpoint routing, optional [`grain_llm_models::Registry`] wiring.
13//! - [`config`] — small config types ([`EnvKeyResolver`],
14//! [`OpenAiCompatEndpoint`], [`OpenAiCompatPreset`], [`ProviderRouter`]).
15
16pub mod builder;
17pub mod config;
18pub mod mapping;
19pub mod oauth;
20pub mod provider;
21pub mod stream;
22
23pub use builder::GenaiStreamBuilder;
24pub use config::{EnvKeyResolver, OpenAiCompatEndpoint, OpenAiCompatPreset, ProviderRouter};
25pub use mapping::inbound::InboundState;
26pub use mapping::outbound::{baseline_chat_options, to_chat_request};
27pub use mapping::usage::map_usage;
28pub use provider::{
29 AuthEntry, ProfileEntry, ProviderAuth, ProviderKind, ProviderProfile, load_profiles,
30 profile_from_entry, resolve_providers_file,
31};
32pub use stream::GenaiStream;