Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
openai-ergonomic
Ergonomic Rust client for the OpenAI API and the services that speak it (Azure OpenAI,
OpenRouter, Groq, Ollama, gateways): fluent builders for chat completions, the Responses API,
embeddings, images, audio, files, assistants, batches and more, on top of the generated
openai-client-base. It sends through a
tower-based HTTP client
(timvw-rust-runtime), natively and on WebAssembly.
Quick start
use Client;
async
Getting started goes on from here: the Responses API, streaming, errors and the examples.
Key features
- Builders for chat completions, the Responses API (
/responses, with typed streaming events and stored-response operations), embeddings, images, audio, files, uploads, vector stores, assistants and threads, batches, fine-tuning, moderations and usage (getting started, API coverage). - Providers:
OpenAI, AzureOpenAI,OpenRouter, Groq, Ollama or anyOpenAI-compatible API, with refreshable credentials (Entra ID tokens, gateways) through anAuthProvider(configuration). - A tower HTTP stack with retries (honouring
Retry-After), timeouts, stream idle timeouts, rate-limit headers, a retry classification of errors and layers of your own (configuration). - Streaming of chat completions and of Responses API events, with completion reports (streaming).
- Tools for chat completions and the Responses API: typed function tools, tools that return images or files, custom (grammar) tools, namespaces and tools only known at runtime (MCP), in a registry that answers every call (tools).
- An agent loop on both APIs:
ToolLoopruns the model's tool calls until it answers, with history repair, calls started while the response streams, ordered parallel dispatch, retries of whole requests, cancellation, deferred tools with a tool search, stateless requests and per-call rate limits (agent loop). - Interceptors around every request and stream, with a Langfuse / OpenTelemetry integration (interceptors).
- Bring your own types: send and decode types of your own through the same client (chat and responses).
- Files and media: parallel, retried large uploads; images, speech and file contents streamed to disk (files and media).
- Webhooks: verify
OpenAIwebhook signatures and decode their events (webhooks). - WebAssembly: builds for
wasm32-unknown-unknown(browsers, Node.js, Cloudflare Workers) (WebAssembly).
Documentation
| Getting started | installing, a client, chat, the Responses API, errors, the examples |
| Configuration | providers (Azure, OpenRouter, Groq, Ollama, custom), authentication, retries, timeouts, custom HTTP clients, per-call options |
| Chat and responses, Responses workflows | the builders, structured output, vision, bring your own types |
| Streaming, completion contract | streamed chat completions and responses, completion reports |
| Tool framework, tool orchestration | typed tools, the registry, answering calls on both APIs, multi-turn tool calling |
| Agent loop | ToolLoop: the tool loop on both APIs, history repair, parallel calls, retries, cancellation, tool search |
| Interceptors, Langfuse integration | hooks around requests and streams, typed state, Langfuse / OpenTelemetry |
| Files and media, vector stores | uploads (Upload), large files, images, speech, downloads |
| Webhooks | signature verification and events (feature webhook) |
| WebAssembly | building for wasm32-unknown-unknown, what differs, the Node.js tests |
| Migration | upgrading release by release |
| Examples index, architecture | the examples/ directory; how the crate is put together |
| Development, contributing | building and testing, local CI, the WebAssembly suite |
| API reference | docs.rs |
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.