Independent Rust SDK for the OpenAI API with Responses-first ergonomics, realtime support, and typed compatibility helpers.
Published package: scalarian-openai-rust. Rust import path: openai_rust.
cargo add scalarian-openai-rustuse openai_rust::OpenAI;
use openai_rust::resources::responses::ResponseCreateParams;
use serde_json::json;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = OpenAI::builder().build();
let response = client.responses().create(ResponseCreateParams {
model: "gpt-4.1-mini".into(),
input: Some(json!("Say hello from Rust.")),
..Default::default()
})?;
println!("{}", response.output.output_text());
Ok(())
}From a local checkout, validate the published surfaces with:
cargo fmt --all --check
cargo test --workspace
cargo check --examples --all-features
cargo test --docIf you want a zero-cost configuration check before making a live request, use client.prepare_request("GET", "/models")? to confirm env-based configuration resolves correctly.
- Responses-first request and streaming flows, including structured outputs and tool schemas.
- Coverage for chat completions, legacy completions, embeddings, files, uploads, vector stores, images, audio, evals, fine-tuning, moderations, and webhooks.
- Realtime session models plus an opt-in blocking facade for synchronous integrations.
- Example-driven docs and contract tests that keep the published API aligned with the repository.
Choose the path that matches your job:
- Quickstart for a fresh integration.
- Responses Guide for structured outputs, streaming, and tool-heavy flows.
- Migration Guide for chat-completions and legacy completions compatibility paths.
- Files and Vector Stores for uploads and retrieval workflows.
- Architecture Note for runtime, transport, and realtime notes.
- API Coverage and Intentional Gaps for surface-level status.
openai_rust::OpenAI: client builder, environment-driven auth, and request preparation.openai_rust::resources: typed REST surfaces for the API families exposed by the crate.openai_rust::realtime: session, event, and state models for Realtime workflows.openai_rust::helpers: multipart uploads, pagination, SSE, structured output, and webhook utilities.openai_rust::blocking: feature-gated blocking facade for non-async callers.
- Start with docs/maintenance.md for validation commands and release-ready checks.
- Use SUPPORT.md to choose between bug reports, docs issues, feature requests, and usage questions.
- Review SECURITY.md before reporting sensitive issues.
- See CHANGELOG.md for release notes and CODE_OF_CONDUCT.md for participation expectations.
- Maintainer: Chaitanya Mishra (@staticpayload).
Apache-2.0. See LICENSE.
Warning
This project is not an official OpenAI product. It is not affiliated with, endorsed by, or supported by OpenAI.