Rust multiprovider generative AI client (Ollama, OpenAi, Anthropic, Gemini, DeepSeek, xAI/Grok, Groq,Cohere, ...)
Rust multiprovider generative AI client (Ollama, OpenAi, Anthropic, Gemini, DeepSeek, xAI/Grok, Groq,Cohere, ...)
A Native-Protocol Multi-AI Provider Library for Rust
# Current release
genai = "0.6"
# Soon to be released (first half of Sept 2026)
genai = "0.7.0-beta"See v0.7.0-beta
v0.7.0-beta | v0.6.x | Key Features | Providers | Examples | Chat Options | Usage | TLS Backends | Contribution
genai provides a single, ergonomic Rust API for native-protocol multi-AI provider access, including Anthropic, OpenAI, Gemini, xAI, Ollama, Groq, and more.
Over 200+ LLM models, 26+ LLM providers out of the box, including Ollama for local execution.
Out-of-the-box providers: openai, openai_resp, anthropic, gemini, omlx, ollama, ollama_cloud, vertex, bedrock_api, bedrock_sigv4, github_copilot, opencode_go, groq, together, fireworks, cohere, nebius, mimo, deepseek, minimax, zai, zai_coding, bigmodel, aliyun, qwen_cloud, baidu, moonshot (moonshot.cn), kimi (moonshot.ai), aihubmix, open_router, atlascloud, xai
Common models like OpenAI, Anthropic, Gemini, can be accessed with their simple name gpt-5.6-luna, claude-..., gemini-... and the right adapter/providers will be selected.
Providers and adapters can also be forced with a namespaced model name via [name_space]::[model_name], for example, qwen_cloud::qwen3.8-max
Custom OpenAI-compatible endpoints can be accessed with the built-in genai_n adapter. Set GENAI_{n}_ENDPOINT and optionally GENAI_{n}_API_KEY, then use the genai_{n}::model_name namespace:
GENAI_1_ENDPOINT=https://my-host.example.com/v1/
GENAI_1_API_KEY=sk-your-api-keylet client = Client::new()?;
let chat_res = client.exec_chat("genai_1::my-model", chat_req, None).await?;For an OMLX deployment, set OMLX_ENDPOINT to the OpenAI-compatible base URL before creating the client. OMLX uses OMLX_API_KEY when authentication is required:
OMLX_ENDPOINT=http://my-omlx-host:8000/v1/
OMLX_API_KEY=your-api-keyThen target the model with the omlx:: namespace:
let client = Client::new()?;
let chat_res = client.exec_chat("omlx::my-model", chat_req, None).await?;Also supports custom endpoints and auth with ServiceTargetResolver (see examples/c06-target-resolver.rs) to support any other providers.
// Can talk to any models / providers
let client = Client::new()?;
let question = "Why is the sky red?";
let chat_req = ChatRequest::new(vec![
ChatMessage::system("Answer in one sentence"),
ChatMessage::user(question),
]);
// Model names can even have a reasoning effort suffix, such as "-high", which will be set, and then removed from name when sent to the provider.
let chat_res = client.exec_chat("gpt-5.4-mini-high", chat_req, None).await?;
println!("{}", chat_res.first_text().unwrap_or("NO ANSWER"));
Docs for LLMs | CHANGELOG | BIG THANKS
v0.7.0 release target: first half of Sept 2026. See latest v0.7.0-beta releases.
Big release: Many fixes, new capabilities, new providers, and minimal API changes.
Key Breaking Changes:
Client::new()? and ClientBuilder::build()? return Result (no more Client::default()).ReasoningEffort::Zero replaces ReasoningEffort::None ("zero" keyword, "none" backward-compatible alias).New Providers & Adapters:
gemini_ix::): stateful conversation sessions (previous_response_id, store).atlascloud::), Qwen Cloud (qwen_cloud::), Kimi (kimi::, kimi-*), OMLX (omlx::, omlx-*).genai_{n}::): generic OpenAI-compatible routing via GENAI_{n}_ENDPOINT and GENAI_{n}_API_KEY.Key Capabilities & Improvements:
ClientBuilder::append_provider_config and ClientConfig::append_provider_config.ChatFrameSink and ChatOptions::with_raw_frame_sink.Tool::with_cache_control) and SSE heartbeat events (ChatStreamEvent::Heartbeat).otel feature flag.See all in CHANGELOG and v0.7.0 migration guide for more details.
New provider since v0.6.0: minimax
v0.6.0 release date: 2026-05-23
Here’s what’s new:
bedrock_api and bedrock_sigv4 adapters)open_routervertex (with Gemini and Anthropic support)github_copilot (GitHub Models API)opencode_gobaidualiyunqwen_cloud (managed Qwen Cloud service at qwencloud.com, using the internal Aliyun-compatible endpoint)moonshotaihubmixollama_cloud (Ollama Cloud)ReasoningEffort::Max for Anthropic and ReasoningEffort::XHigh for OpenAI.Client::all_model_names(adapter_kind, provider_config) now accepts endpoint and auth overrides, including remote Ollama hosts and custom OpenAI-compatible model listing.const, nullable schema patterns, additionalProperties, and JSON Schema-only keywords rejected by Vertex.ClientBuilder::with_adapter_kind(...) and ClientConfig::with_adapter_kind(...) bind a client to a single provider adapter, which is useful for proxies, gateways, Azure-style deployment names, and OpenAI-compatible providers with nonstandard model names.ModelIden, or complete ServiceTarget, enabling custom endpoints, auth, and model identity without relying on model-name inference.previous_response_id, request store, and returned response_id.ChatOptions::with_extra_body(...) provides a low-level request body extension point for provider-specific fields in OpenAI-compatible chat payloads.ChatOptions::with_tool_choice(...) adds provider-neutral tool selection hints for automatic, disabled, required, or specific tool calls.ToolName, ToolConfig, WebSearch, and provider mappings for Anthropic, OpenAI, and Gemini.CacheControl support adds provider-specific prompt caching options, including OpenAI prompt_cache_key and cache retention. On Anthropic, Tool::with_cache_control marks individual tools, and request-level ChatOptions::with_cache_control auto-applies a breakpoint to the static (tools+system) prefix.ReasoningContent and StopReason handling (v0.6.0-beta.20), including ContentPart::ReasoningContent and provider stop reasons.TCP_NODELAY, and HTTP/2 tuning.See v0.5.x to v0.6.x migration
See CHANGELOG
See BIG-THANKS for contributors
Examples | Thanks | Library Focus | Changelog | Provider Mapping: ChatOptions | Usage
By default, the library resolves the AdapterKind (AI provider) based on the model name prefix:
gpt-* (most), o1-*, o3-*, o4-*, chatgpt-*, codex-*gpt-5-*, gpt-6-*, gpt-* (containing codex or pro)claude-*gemini-*grok-*deepseek-*moonshot-* (moonshot.ai)kimi* (moonshot.ai)glm-*command-*, embed-*mimo-*opencode_go:: onlyatlascloud:: onlyqwen_cloud:: only, for the managed Qwen Cloud service at qwencloud.com. It uses the internal Aliyun-compatible endpoint and QWEN_CLOUD_API_KEY.fireworksYou can force a specific adapter by using the adapter_kind::model_name syntax. This is the recommended way for many providers and for disambiguating OpenAI-compatible services.
groq::openai/gpt-oss-20b (Forces Groq adapter)together::meta-llama/Llama-3-8b-chat-hf (Forces Together adapter)fireworks::glm-5p1 (for fireworks.ai)ollama_cloud::gemma3:4b (Forces Ollama Cloud adapter)github_copilot::openai/gpt-5.4-mini (Forces GitHub Copilot adapter)nebius::Qwen/Qwen3-235B-A22B (Forces Nebius adapter)aliyun::qwen-plus (Forces Aliyun adapter)qwen_cloud::qwen-plus (Forces Qwen Cloud adapter, managed by qwencloud.com and backed by the internal Aliyun-compatible service)vertex::gemini-2.5-flash (Forces Google Vertex adapter)moonshot::moonshot-v1-8k (Forces Moonshot adapter)baidu::ernie-4.0 (Forces Baidu adapter)zai_coding::glm-4.6 (Special namespace for Zai coding subscription)opencode_go::minimax-m2.5 (Forces OpenCode Go adapter)bedrock_api::anthropic.claude-v2 (Forces AWS Bedrock adapter)open_router::google/gemini-2.0-flash-001 (Forces OpenRouter adapter)atlascloud::qwen/qwen3.5-flash (Forces Atlas Cloud adapter)genai_1::my-model-7b (Forces Custom adapter with index 1)For a complete list of AdapterKind, see the AdapterKind enum.
…AuthResolver to supply auth data, such as api_key, per adapter kind.AdapterKindResolver to customize the "model nameNo open issues yet, or sync has not completed.