NAME
Langertha::Engine::OpenAI - OpenAI API
VERSION
version 0.303
SYNOPSIS
use Langertha::Engine::OpenAI;
my $openai = Langertha::Engine::OpenAI->new(
api_key => $ENV{OPENAI_API_KEY},
model => 'gpt-4o-mini',
system_prompt => 'You are a helpful assistant',
temperature => 0.7,
);
my $response = $openai->simple_chat('Say something nice');
print $response;
# Embeddings
my $embedding = $openai->embedding('Some text to embed');
# Transcription (Whisper)
my $text = $openai->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;
}
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-4o-mini (default, fast), gpt-4o (most capable), o1/o3-mini (reasoning), text-embedding-3-large (embeddings), whisper-1 (transcription).
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.
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.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <torsten@raudssus.de> https://raudss.us/
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.