Rust

Use async-openai with 000 Labs.

Cargo.toml
[dependencies]
async-openai = "0.28"
tokio = { version = "1", features = ["full"] }
main.rs
use async_openai::{config::OpenAIConfig, types::*, Client};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = OpenAIConfig::new()
        .with_api_base("https://api.000labs.xyz/v1")
        .with_api_key(std::env::var("000_LABS_API_KEY")?);
    let client = Client::with_config(config);

    let request = CreateChatCompletionRequestArgs::default()
        .model("openai/gpt-4o-mini")
        .messages([ChatCompletionRequestUserMessageArgs::default()
            .content("What is the meaning of life?")
            .build()?
            .into()])
        .build()?;

    let response = client.chat().create(request).await?;
    println!("{:?}", response.choices[0].message.content);
    Ok(())
}