NAME
Langertha::Engine::OpenAI - OpenAI API
VERSION
version 0.503
SYNOPSIS
use Langertha::Engine::OpenAI;
my $openai = Langertha::Engine::OpenAI->new(
api_key => $ENV{OPENAI_API_KEY},
model => 'gpt-5.6-terra',
system_prompt => 'You are a helpful assistant',
temperature => 0.7,
);
my $response = $openai->simple_chat('Say something nice');
print $response;
# Embeddings
my $vector = $openai->simple_embedding('Some text to embed');
# Transcription (Whisper)
my $text = $openai->simple_transcription('/path/to/audio.mp3');
# Async with Future::AsyncAwait
use Future::AsyncAwait;
async sub ask_gpt {
my $response = await $openai->simple_chat_f('What is Perl?');
say $response;
my $vector = await $openai->simple_embedding_f('Some text to embed');
}
DESCRIPTION
Provides access to OpenAI's APIs, including GPT models, embeddings, and Whisper transcription. Composes Langertha::Role::OpenAICompatible for the standard OpenAI API format.
Popular models: gpt-6-astra (GPT-6 flagship — 1.05M-token context, 128K max output, text+image input, knowledge cutoff 2026-04-30), gpt-5.6-terra (default, balances intelligence and cost — the GPT-5.6 successor of the former mini tier), gpt-5.6 (Sol, frontier), gpt-5.6-luna (cost-sensitive, successor of the former nano tier), text-embedding-3-large (embeddings), gpt-transcribe (transcription, default), gpt-image-2 (image generation, default).
Dynamic model listing is supported via "list_models" in Langertha::Role::Models. Results are cached for models_cache_ttl seconds (default: 3600).
Get your API key at https://platform.openai.com/ and set LANGERTHA_OPENAI_API_KEY in your environment.
THIS API IS WORK IN PROGRESS
compatibility_for_engine
Optional identifier of the engine this instance is acting as a compatibility shim for. Used internally when one engine is accessed via another's OpenAI endpoint.
whisper
Lazy-built Langertha::Engine::TranscriptionBase instance bound to this engine's api_key, url, transcription_model (gpt-transcribe unless set), user_agent_agent, user_agent_timeout and "connect_address" in Langertha::Role::HTTP, so it transcribes exactly as $openai->simple_transcription does. Useful when you have an OpenAI engine handy and want a focused transcription handle without re-stating credentials:
my $text = $openai->whisper->simple_transcription('/path/audio.mp3');
The transcription engine is fully independent: configure it directly (temperature, language, etc.) via the returned object, or construct your own Langertha::Engine::TranscriptionBase if you need a different model or endpoint.
SEE ALSO
https://status.openai.com/ - OpenAI service status
https://platform.openai.com/docs - Official OpenAI documentation
Langertha::Role::OpenAICompatible - OpenAI API format role composed by this engine
Langertha::Role::Tools - MCP tool calling interface
Langertha::Engine::DeepSeek - DeepSeek (via OpenAICompatible role)
Langertha::Engine::Groq - Groq (via OpenAICompatible role)
Langertha::Engine::Mistral - Mistral (via OpenAICompatible role)
Langertha::Engine::vLLM - vLLM inference server (via OpenAICompatible role)
Langertha::Engine::NousResearch - Nous Research (via OpenAICompatible role)
Langertha::Engine::Perplexity - Perplexity Sonar (via OpenAICompatible role)
SUPPORT
Issues
Please report bugs and feature requests on GitHub at https://github.com/Getty/langertha/issues.
IRC
Join #langertha on irc.perl.org or message Getty directly.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <getty@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus https://raudssus.de/.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.