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:

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

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.