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
| Provider | Feature | API Format |
|---|---|---|
| OpenAI | openai | OpenAI Chat Completions |
| Anthropic | anthropic | Anthropic Messages |
| Gemini | gemini | Google Gemini |
| Ollama | ollama | OpenAI-compatible |
DeepSeek | deepseek | OpenAI-compatible |
Grok (xAI) | grok | OpenAI-compatible |
Z.ai | zai | Anthropic Messages |
| Azure OpenAI | azure | OpenAI-compatible |
| Moonshot AI | moonshot | OpenAI-compatible |
| AWS Bedrock | bedrock | Bedrock Converse/native |
| Self-hosted | any | OpenAI-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
OpenAiClientpointed at the resource’s v1 API. - deepseek
DeepSeekclient — anOpenAiClientpointed at theDeepSeekAPI.- grok
Grok(xAI) client — anOpenAiClientpointed at the xAI API.- moonshot
- Moonshot AI (Kimi) client — an
OpenAiClientpointed at the Moonshot API. - ollama
- Ollama client — an
OpenAiClientpointed at an Ollama server. - self_
hosted - Self-hosted client — an
OpenAiClientpointed at any custom endpoint. - zai
Z.ai(ZhipuAI/BigModel) client — anAnthropicClientpointed at theZ.aiAnthropic-compatible API.