NAME
OpenAI::API::Config - Configuration options for OpenAI::API
SYNOPSIS
use OpenAI::API::Config;
my $config = OpenAI::API::Config->new(
api_base => 'https://api.openai.com/v1',
timeout => 60,
retry => 3,
sleep => 1,
);
# Later...
{
use OpenAI::API;
my $openai = OpenAI::API->new( config => $config );
my $res = $openai->models();
}
# or...
{
use OpenAI::API::Request::Model::List;
my $request = OpenAI::API::Request::Model::List->new( config => $config );
my $res = $request->send();
}
DESCRIPTION
This module defines a configuration object for the OpenAI API client. It provides default values for various options, such as the API base URL, the API key, and the timeout period for API requests.
ATTRIBUTES
api_key
The API key to use when making requests to the OpenAI API. This is a required attribute, and if not provided, it will default to the value of the
OPENAI_API_KEY
environment variable.api_base
The base URL for the OpenAI API. This defaults to 'https://api.openai.com/v1', but can be overridden by setting the
OPENAI_API_BASE
environment variable.timeout
The timeout period (in seconds) for API requests. This defaults to 60 seconds.
retry
The number of times to retry a failed API request. This defaults to 3 retries.
sleep
The number of seconds to wait between retry attempts. This defaults to 1 second.
METHODS
new(%args)
Constructs a new OpenAI::API::Config object with the provided options. The available options are the same as the attributes listed above.
SEE ALSO
OpenAI::API::Request modules