openai-rust2
Unofficial async Rust client for the OpenAI API and OpenAI-compatible endpoints (xAI Grok, Ollama, OpenRouter, self-hosted gateways, …).
This is a maintained fork published as openai-rust2 (original: openai-rust).
Features
- List models
- Chat Completions (+ streaming)
- Completions (legacy)
- Embeddings
- Images
- xAI Agent Tools / Responses API (
create_responses) - OpenAI Responses API tools (
web_search,file_search,code_interpreter) - Shared connection-pooled HTTP client + application-level retry on transient failures
- Audio / Files / Moderations / Fine-tuning
Quick start
use openai_rust2 as openai_rust;
async
Local Ollama (or any OpenAI-compatible base URL):
use openai_rust2 as openai_rust;
let client = new_with_base_url;
Run the chat example:
OPENAI_API_KEY=sk-...
Development
Projects using this crate
- cloudllm — agent toolkit (LLMSession, multi-provider clients, MentisDB)
- uninews — universal news scraper (via cloudllm)
License
MIT