open_ai_rust 1.1.1

Idiomatic Rust SDK for the OpenAI API: chat, responses, embeddings, audio, images, moderations, files, batches, vector stores, fine-tuning. Builder payloads, typed function-call schemas, streaming, per-request retries/timeouts.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//! Run with: `OPENAI_API_KEY=sk-... cargo run --example embed_text`
use open_ai_rust::Client;

#[tokio::main]
async fn main() -> open_ai_rust::Result<()> {
    dotenv::dotenv().ok();
    let client = Client::from_env()?;

    let v = client
        .embeddings()
        .create_one("Hello, embeddings!", "text-embedding-3-small")
        .await?;
    println!("dim={} sample={:?}", v.len(), &v[..5.min(v.len())]);
    Ok(())
}