🦀

Rust

SDK

The async-openai crate is a popular community-maintained Rust client for the OpenAI API. It supports custom base URLs, so pointing it at Qubax is a one-line change in your configuration.

Official docs

Install

Shell
cargo add async-openai

Quickstart

rust
use async_openai::{
    config::OpenAIConfig,
    types::{ChatCompletionRequestUserMessageArgs, CreateChatCompletionRequestArgs},
    Client,
};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = OpenAIConfig::new()
        .with_api_base("https://api.qubax.ai/v1")
        .with_api_key("YOUR_API_KEY");

    let client = Client::with_config(config);

    let request = CreateChatCompletionRequestArgs::default()
        .model("gpt-5")
        .messages([ChatCompletionRequestUserMessageArgs::default()
            .content("Explain quantum entanglement in one sentence.")
            .build()?
            .into()])
        .build()?;

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

    Ok(())
}

Setup steps

  1. 1

    Add the crate

    Run cargo add async-openai (or add it manually to Cargo.toml). Tokio is required as a runtime.

  2. 2

    Configure the client

    Build an OpenAIConfig with .with_api_base("https://api.qubax.ai/v1") and .with_api_key set to your Qubax key, then create a Client.

  3. 3

    Make a request

    Construct a CreateChatCompletionRequestArgs with model gpt-5 and your messages, then call client.chat().create(request).await.

ℹ️
You can also set OPENAI_API_KEY and OPENAI_API_BASE environment variables instead of hardcoding them.

Test your connection

Paste your Qubax API key and send a live request to verify everything is wired up. Don't have a key yet?

Create one in the dashboard