glopenai/config

Types

Configuration for Azure OpenAI Service.

pub type AzureConfig {
  AzureConfig(
    api_base: String,
    api_key: String,
    deployment_id: String,
    api_version: String,
  )
}

Constructors

  • AzureConfig(
      api_base: String,
      api_key: String,
      deployment_id: String,
      api_version: String,
    )

Configuration for OpenAI API requests.

pub type Config {
  Config(
    api_base: String,
    api_key: String,
    org_id: option.Option(String),
    project_id: option.Option(String),
    custom_headers: List(#(String, String)),
  )
}

Constructors

  • Config(
      api_base: String,
      api_key: String,
      org_id: option.Option(String),
      project_id: option.Option(String),
      custom_headers: List(#(String, String)),
    )

Values

pub const default_api_base: String

Default OpenAI API v1 base URL.

pub fn new(api_key api_key: String) -> Config

Create a new config with the given API key and the default base URL.

pub fn new_azure(
  api_base api_base: String,
  api_key api_key: String,
  deployment_id deployment_id: String,
  api_version api_version: String,
) -> AzureConfig

Create a new Azure config.

pub fn with_api_base(config: Config, api_base: String) -> Config

Set a custom API base URL (e.g. for proxies or compatible APIs).

pub fn with_header(
  config: Config,
  key: String,
  value: String,
) -> Config

Add a custom header to all requests.

pub fn with_org_id(config: Config, org_id: String) -> Config

Set the organization ID header (OpenAI-Organization).

pub fn with_project_id(
  config: Config,
  project_id: String,
) -> Config

Set the project ID header (OpenAI-Project).

Search Document