![]() |
![]()
| ![]() |
![]()
NAMEOpenAI::API - Perl interface to OpenAI API SYNOPSISuse OpenAI::API; my $openai = OpenAI::API->new(); # uses OPENAI_API_KEY environment variable my $res = $openai->chat( messages => [ { "role" => "system", "content" => "You are a helpful assistant." }, { "role" => "user", "content" => "How can I access OpenAI's APIs in Perl?" }, { "role" => "assistant", "content" => "You can use the OpenAI::API module." }, { "role" => "user", "content" => "Where can I find this module?" }, ], max_tokens => 20, temperature => 0, ); my $message = $res->{choices}[0]{message}; # or simply: my $message = "$res"; DESCRIPTIONOpenAI::API is a Perl module that provides an interface to the OpenAI API, which allows you to generate text, translate languages, summarize text, and perform other tasks using the language models developed by OpenAI. To use the OpenAI::API module, you will need an API key, which you can obtain by signing up for an account on the OpenAI website <https://platform.openai.com>. METHODSOpenAI::API acts as a high-level interface for the OpenAI API, handling different actions while utilizing the configuration class. new()Creates a new OpenAI::API object.
chat()Chat request. completions()Completion request. edits()Edit request. embeddings()Embedding request. files()File List request. file_retrieve()File Retrieve request. image_create()Image Generation request. models()Model List request. model_retrieve()Model Retrieve request. moderations()Moderation request. RESOURCES
SEE ALSOOpenAI Reference Overview <https://platform.openai.com/docs/api-reference/overview> AUTHORNelson Ferraz <nferraz@gmail.com> SUPPORTThis module is developed on GitHub <https://github.com/nferraz/perl-openai-api>. Send ideas, feedback, tasks, or bugs to GitHub Issues <https://github.com/nferraz/perl-openai-api/issues>. COPYRIGHT AND LICENSECopyright (C) 2022, 2023 by Nelson Ferraz This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.30.2 or, at your option, any later version of Perl 5 you may have available.
|