Skip to main content

ante_llm/
lib.rs

1// Copyright 2026 Antigma Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4#![doc = include_str!("../README.md")]
5
6/// The Anthropic Messages API.
7pub mod anthropic;
8pub mod auth;
9/// The [`ChatClient`](client::ChatClient) trait every provider implements,
10/// and the [`Client`](client::Client) that sends a provider's HTTP requests.
11pub mod client;
12mod compress;
13pub mod effort;
14pub mod error;
15mod extra_body;
16/// The Gemini API.
17pub mod gemini;
18/// The OpenAI Responses API, over HTTP streaming or a WebSocket.
19pub mod openai;
20/// OpenAI Chat Completions and the servers that speak it, with per-provider
21/// profiles for reasoning parameters.
22pub mod openai_compatible;
23mod retry_policy;
24pub mod search;
25mod stream_driver;
26pub mod streaming;
27mod system_messages;
28#[cfg(test)]
29pub(crate) mod test_support;
30/// The provider-neutral request, conversation, and stream event types.
31pub mod types;
32
33use serde::{Deserialize, Serialize};
34
35use self::types::Effort;
36
37/// The wire dialect a provider speaks: which request converter, response
38/// mapper, and reserved request fields apply.
39#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
40pub enum WireStyle {
41    /// Anthropic Messages.
42    #[default]
43    AnthropicMessage,
44    /// OpenAI Chat Completions.
45    OpenAiCompatible,
46    /// OpenAI Responses.
47    OpenAiResponse,
48    /// Gemini.
49    Gemini,
50}
51
52impl WireStyle {
53    /// The effort levels a model offers on this wire, ascending and distinct:
54    /// the `declared` ones the wire can express, or the wire's own for that
55    /// model when it declares none. `provider_id` matters on the
56    /// OpenAI-compatible wire only.
57    pub fn effort_levels(
58        &self,
59        provider_id: &str,
60        model_id: &str,
61        declared: Option<&[Effort]>,
62    ) -> Vec<Effort> {
63        match self {
64            Self::AnthropicMessage => anthropic::effort_levels(model_id, declared),
65            Self::OpenAiResponse => openai::effort_levels(declared),
66            Self::Gemini => gemini::effort_levels(declared),
67            Self::OpenAiCompatible => {
68                crate::openai_compatible::effort_levels(provider_id, model_id, declared)
69            }
70        }
71    }
72}
73
74/// The default maximum number of tokens
75pub const DEFAULT_MAX_TOKENS: u32 = 64000;