GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
OpenAI::API::Config(3) User Contributed Perl Documentation OpenAI::API::Config(3)

OpenAI::API::Config - Configuration options for OpenAI::API

    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();
    }

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.

  • 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.

  • event_loop_class

    IO::Async event loop class (if you are doing asynchronous programming).

    Default: IO::Async::Loop.

    Possible values:

  • IO::Async::Loop::AnyEvent
  • IO::Async::Loop::Mojo
  • IO::Async::Loop::POE
  • and many others

new(%args)

Constructs a new OpenAI::API::Config object with the provided options. The available options are the same as the attributes listed above.

  • OpenAI::API
  • OpenAI::API::Request modules
2023-04-09 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.