NAME

Langertha::Knarr::Handler::Passthrough - Knarr handler that forwards requests verbatim to an upstream HTTP API

VERSION

version 1.001

SYNOPSIS

use Langertha::Knarr::Handler::Passthrough;

my $handler = Langertha::Knarr::Handler::Passthrough->new(
    upstreams => {
        openai    => 'https://api.openai.com',
        anthropic => 'https://api.anthropic.com',
        ollama    => 'http://localhost:11434',
    },
);

DESCRIPTION

Forwards the original wire-format request verbatim to a real upstream API. The protocol's parser already turned the body into a Langertha::Knarr::Request; Passthrough rebuilds the upstream JSON from $request->raw and re-POSTs it.

Both sync and streaming requests are supported. For streaming, the upstream's protocol-native chunks are extracted into plain text deltas which the front-side protocol then re-frames — keeping symmetry even when client and upstream use the same protocol.

This is the building block behind Knarr's classic "configure your API keys once, point everything at me" use case.

upstreams

Required. HashRef mapping protocol name (openai, anthropic, ollama) to upstream base URL. The protocol's default chat path is appended.

default_auth

Optional. An Authorization header value to inject when the client didn't send one. Usually you let the client supply its own key.

model_id

Optional. Defaults to passthrough.

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/Getty/langertha-knarr/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 <torsten@raudssus.de> https://raudssus.de/

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.