glean/models/openai

OpenAI GPT models that accept sampling parameters (GPT-4.1 and GPT-4o families).

GPT-5 and later are reasoning models that reject a non-default temperature; use glean/models/openai_reasoning for those.

Types

A GPT (non-reasoning) model builder. Pick a model with one of the constructors (or custom), chain setters, then call build().

pub opaque type Gpt

Values

pub fn build(m: Gpt) -> model.Model

Build a Model to use with agent.new.

pub fn configure(
  m: Gpt,
  f: fn(config.ProviderConfig) -> config.ProviderConfig,
) -> Gpt

Change the provider configuration: base URL, timeout, headers, retries.

|> configure(config.timeout(_, 120_000))
pub fn custom(api_key key: String, model model_id: String) -> Gpt

Any other model ID served by this API, such as one released after this version of glean. Only this module’s setters are available, so check the model accepts them.

pub fn frequency_penalty(m: Gpt, fp: Float) -> Gpt

Set the frequency penalty.

pub fn gpt4_1(api_key key: String) -> Gpt

GPT-4.1. Model ID: gpt-4.1.

pub fn gpt4_1_mini(api_key key: String) -> Gpt

GPT-4.1 mini. Model ID: gpt-4.1-mini.

pub fn gpt4_1_nano(api_key key: String) -> Gpt

GPT-4.1 nano. Model ID: gpt-4.1-nano.

pub fn gpt4o(api_key key: String) -> Gpt

GPT-4o. Model ID: gpt-4o.

pub fn gpt4o_mini(api_key key: String) -> Gpt

GPT-4o mini. Model ID: gpt-4o-mini.

pub fn max_output_tokens(m: Gpt, n: Int) -> Gpt

Set the maximum number of output tokens.

pub fn presence_penalty(m: Gpt, pp: Float) -> Gpt

Set the presence penalty.

pub fn seed(m: Gpt, s: Int) -> Gpt

Set the random seed for more repeatable output.

pub fn stop_sequences(m: Gpt, stops: List(String)) -> Gpt

Stop generating when the model writes any of these strings.

pub fn temperature(m: Gpt, t: Float) -> Gpt

Set the sampling temperature.

pub fn top_p(m: Gpt, p: Float) -> Gpt

Set the top-p (nucleus sampling) value.

✨ Search Document