NAME
Langertha::Engine::OpenAIBase - Base class for OpenAI-compatible engines
VERSION
version 0.302
SYNOPSIS
package My::CompatibleEngine;
use Moose;
extends 'Langertha::Engine::OpenAIBase';
has '+url' => ( default => 'https://api.example.com/v1' );
sub _build_api_key {
return $ENV{MY_API_KEY} || die "MY_API_KEY required";
}
sub default_model { 'my-model-v1' }
__PACKAGE__->meta->make_immutable;
DESCRIPTION
Intermediate base class for all engines that speak the OpenAI /chat/completions API format. Extends Langertha::Engine::Remote and composes the full set of OpenAI-compatible roles: Langertha::Role::OpenAICompatible, Langertha::Role::OpenAPI, Langertha::Role::Models, Langertha::Role::Temperature, Langertha::Role::ResponseSize, Langertha::Role::SystemPrompt, Langertha::Role::Streaming, and Langertha::Role::Chat.
Subclasses must override default_model to return their default model name. They also typically override _build_api_key to read from an environment variable, and has '+url' to supply a default API endpoint.
Concrete engines that extend this class:
Cloud providers — Langertha::Engine::OpenAI, Langertha::Engine::DeepSeek, Langertha::Engine::Groq, Langertha::Engine::Mistral, Langertha::Engine::Cerebras, Langertha::Engine::MiniMax, Langertha::Engine::NousResearch, Langertha::Engine::OpenRouter, Langertha::Engine::Replicate, Langertha::Engine::HuggingFace, Langertha::Engine::Perplexity, Langertha::Engine::AKIOpenAI
Self-hosted — Langertha::Engine::OllamaOpenAI, Langertha::Engine::vLLM, Langertha::Engine::LlamaCpp
default_model
Abstract. Subclasses must override this to return the default model name string. The base implementation croaks with a descriptive error message.
sub default_model { 'gpt-4o-mini' }
SEE ALSO
Langertha::Engine::Remote - Parent base class
Langertha::Role::OpenAICompatible - OpenAI API format (chat, embeddings, tools, streaming)
Langertha::Role::Chat -
simple_chat,simple_chat_f, streaming methodsLangertha::Role::Models -
model,models,list_modelsLangertha::Role::Temperature -
temperatureattributeLangertha::Role::ResponseSize -
response_size/max_tokensLangertha::Role::SystemPrompt -
system_promptattributeLangertha::Role::Streaming - SSE stream parsing
Langertha::Engine::OpenAI - Canonical OpenAI engine
Langertha::Engine::Groq - Groq ultra-fast inference
Langertha::Engine::DeepSeek - DeepSeek reasoning models
Langertha::Engine::OllamaOpenAI - Ollama OpenAI-compatible endpoint
Langertha::Engine::vLLM - vLLM high-throughput inference server
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.