OpenAI.Responses.Config (openai_responses v0.2.1)

Configuration management for the OpenAI Responses API client.

This module handles configuration options and environment variables.

Summary

Functions

Gets the API key from the configuration or environment.

Gets a value from the configuration, with an optional default.

Creates a new configuration map with the provided options.

Functions

api_key(config)

@spec api_key(map()) :: String.t()

Gets the API key from the configuration or environment.

Looks for the API key in the following places, in order:

  1. The :api_key key in the config map
  2. The OPENAI_API_KEY environment variable

Parameters

  • config - The configuration map

Returns

  • The API key, or raises an error if not found

get(config, key, default \\ nil)

@spec get(map(), atom(), any()) :: any()

Gets a value from the configuration, with an optional default.

Parameters

  • config - The configuration map
  • key - The key to look up
  • default - The default value if the key is not found

new(opts \\ [])

@spec new(keyword()) :: map()

Creates a new configuration map with the provided options.

Options

  • :api_key - Your OpenAI API key (overrides environment variable)
  • :api_base - The base URL for API requests
  • Other options used by the client