Skip to content

scalarian/openai-rust

scalarian-openai-rust

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.

CI License: Apache-2.0

Quickstart

cargo add scalarian-openai-rust
use 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 --doc

If 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.

Capability Overview

  • 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.

Start Here

Choose the path that matches your job:

Crate Map

  • 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.

Contributing and Releases

License

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.

About

Rust-native OpenAI SDK with Responses-first ergonomics, realtime sessions, uploads, and typed compatibility helpers.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages