Rust

openai

Module

OpenAI.

Contents

use utopia_agents::OpenAi;
Rust
pub struct OpenAi(Chat)

OpenAI's chat completions: answers streamed token by token, or, with a schema, a JSON answer in strict json_schema mode. Images attach as data URLs. gpt-5-nano only takes temperature 1 (another is replaced, with a warning on standard error), and the o-series and gpt-5-nano take max_completion_tokens instead of max_tokens.

Rust
use utopia_agents::{Adapter, OpenAi, adapters::openai};

let adapter = OpenAi::new("test-api-key").with_model(openai::MODEL_GPT_4O).with_max_tokens(2048);
assert_eq!(adapter.name(), "openai");
assert_eq!(adapter.model(), "gpt-4o");
assert_eq!(adapter.endpoint(), "https://api.openai.com/v1/chat/completions");
Rust
pub const ENDPOINT: &str = "https://api.openai.com/v1/chat/completions"

The chat completions endpoint.

Rust
pub const MODEL_GPT_4_1: &str = "gpt-4.1"

GPT-4.1.

Rust
pub const MODEL_GPT_4_5_PREVIEW: &str = "gpt-4.5-preview"

GPT-4.5 Preview.

Rust
pub const MODEL_GPT_4O: &str = "gpt-4o"

GPT-4o: multimodal, text and images.

Rust
pub const MODEL_GPT_5_NANO: &str = "gpt-5-nano"

GPT-5 Nano: a small GPT-5 for low latency and cost-sensitive work.

Rust
pub const MODEL_O3: &str = "o3"

o3.

Rust
pub const MODEL_O3_MINI: &str = "o3-mini"

o3-mini (the default).

Rust
pub const MODEL_O4_MINI: &str = "o4-mini"

o4-mini.

Rust
pub const MODELS: &[&str] = &[MODEL_GPT_5_NANO, MODEL_GPT_4_5_PREVIEW, MODEL_GPT_4_1, MODEL_GPT_4O, MODEL_O4_MINI, MODEL_O3, MODEL_O3_MINI]

Undocumented.