Skip to main content

Module provider

Module provider 

Source
Expand description

LLM provider clients.

This module provides ready-to-use ApiClient implementations for common LLM providers. Each provider is behind a feature flag so you only compile what you need.

§Feature Flags

ProviderFeatureAPI Format
OpenAIopenaiOpenAI Chat Completions
AnthropicanthropicAnthropic Messages
GeminigeminiGoogle Gemini
OllamaollamaOpenAI-compatible
DeepSeekdeepseekOpenAI-compatible
Grok (xAI)grokOpenAI-compatible
Z.aizaiAnthropic Messages
Azure OpenAIazureOpenAI-compatible
Moonshot AImoonshotOpenAI-compatible
AWS BedrockbedrockBedrock Converse/native
Self-hostedanyOpenAI-compatible

Any provider that exposes an OpenAI-compatible Chat Completions API can use OpenAiClient with a custom base URL. The convenience constructors below pre-configure the correct endpoints.

§Quick Start

use loopctl::provider;
use loopctl::engine::BareLoop;
use loopctl::engine::RunConfig;
use loopctl::engine::core::Loop;

// OpenAI:
let client = provider::OpenAiClient::from_env()?;

// DeepSeek:
let client = provider::deepseek()?;

// Anthropic:
let client = provider::AnthropicClient::from_env()?;

// Gemini:
let client = provider::GeminiClient::from_env()?;

// Ollama (local):
let client = provider::ollama("llama3")?;

// Self-hosted (vLLM, LM Studio, etc.):
let client = provider::self_hosted("http://localhost:8080/v1", "my-model")?;

let agent = BareLoop::new(
    std::sync::Arc::new(client),
    tool_registry,
    config,
);
let result = agent.run("Hello!", &RunConfig::default()).await?;

Re-exports§

pub use openai::OpenAiClient;
pub use anthropic::AnthropicClient;
pub use gemini::GeminiClient;
pub use grammar::JsonSchemaGrammar;
pub use grammar::ToolGrammarProvider;
pub use bedrock::BedrockClient;

Modules§

anthropic
Anthropic Messages API client.
bedrock
AWS Bedrock provider — SigV4-authenticated, two invoke paths.
gemini
Google Gemini API client.
grammar
Tool-call grammar providers for grammar-aware samplers.
openai
OpenAI-compatible API client.

Functions§

azure
Azure OpenAI client — an OpenAiClient pointed at the resource’s v1 API.
deepseek
DeepSeek client — an OpenAiClient pointed at the DeepSeek API.
grok
Grok (xAI) client — an OpenAiClient pointed at the xAI API.
moonshot
Moonshot AI (Kimi) client — an OpenAiClient pointed at the Moonshot API.
ollama
Ollama client — an OpenAiClient pointed at an Ollama server.
self_hosted
Self-hosted client — an OpenAiClient pointed at any custom endpoint.
zai
Z.ai (ZhipuAI / BigModel) client — an AnthropicClient pointed at the Z.ai Anthropic-compatible API.