ante-llm 0.4.2

Streaming LLM client for Anthropic, OpenAI, Gemini and Chat Completions servers, from the Ante coding agent
Documentation
// Copyright 2026 Antigma Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

#![doc = include_str!("../README.md")]

/// The Anthropic Messages API.
pub mod anthropic;
pub mod auth;
/// The [`ChatClient`](client::ChatClient) trait every provider implements,
/// and the [`Client`](client::Client) that sends a provider's HTTP requests.
pub mod client;
mod compress;
pub mod effort;
pub mod error;
mod extra_body;
/// The Gemini API.
pub mod gemini;
/// The OpenAI Responses API, over HTTP streaming or a WebSocket.
pub mod openai;
/// OpenAI Chat Completions and the servers that speak it, with per-provider
/// profiles for reasoning parameters.
pub mod openai_compatible;
mod retry_policy;
pub mod search;
mod stream_driver;
pub mod streaming;
mod system_messages;
#[cfg(test)]
pub(crate) mod test_support;
/// The provider-neutral request, conversation, and stream event types.
pub mod types;

use serde::{Deserialize, Serialize};

use self::types::Effort;

/// The wire dialect a provider speaks: which request converter, response
/// mapper, and reserved request fields apply.
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
pub enum WireStyle {
    /// Anthropic Messages.
    #[default]
    AnthropicMessage,
    /// OpenAI Chat Completions.
    OpenAiCompatible,
    /// OpenAI Responses.
    OpenAiResponse,
    /// Gemini.
    Gemini,
}

impl WireStyle {
    /// The effort levels a model offers on this wire, ascending and distinct:
    /// the `declared` ones the wire can express, or the wire's own for that
    /// model when it declares none. `provider_id` matters on the
    /// OpenAI-compatible wire only.
    pub fn effort_levels(
        &self,
        provider_id: &str,
        model_id: &str,
        declared: Option<&[Effort]>,
    ) -> Vec<Effort> {
        match self {
            Self::AnthropicMessage => anthropic::effort_levels(model_id, declared),
            Self::OpenAiResponse => openai::effort_levels(declared),
            Self::Gemini => gemini::effort_levels(declared),
            Self::OpenAiCompatible => {
                crate::openai_compatible::effort_levels(provider_id, model_id, declared)
            }
        }
    }
}

/// The default maximum number of tokens
pub const DEFAULT_MAX_TOKENS: u32 = 64000;