NAME
Langertha::Stream::Chunk - Represents a single chunk from a streaming response
VERSION
version 0.202
SYNOPSIS
my $stream = $engine->simple_chat_stream_iterator('Tell me a story');
while (my $chunk = $stream->next) {
print $chunk->content;
if ($chunk->is_final) {
say "\nModel: ", $chunk->model if $chunk->has_model;
say "Finish: ", $chunk->finish_reason if $chunk->has_finish_reason;
}
}
DESCRIPTION
A single text chunk delivered during a streaming LLM response. Each chunk carries incremental content text and optional metadata. Chunks are collected into a Langertha::Stream iterator by "simple_chat_stream_iterator" in Langertha::Role::Chat.
content
The incremental text content delivered in this chunk. Required. For most chunks this is a word or partial word; the final chunk may be an empty string.
raw
The raw parsed API response data for this chunk as a HashRef. Use has_raw to check whether it was provided.
is_final
Boolean flag set to 1 on the last chunk of a stream. Defaults to 0.
model
The model identifier returned by the provider, if present. Use has_model to check availability.
finish_reason
The reason the stream ended: stop, length, tool_calls, etc. Provider-specific values are preserved as-is. undef on non-final chunks. Use has_finish_reason to check availability.
usage
Token usage counts as a HashRef, if provided by the engine on the final chunk. Keys vary by provider. Use has_usage to check availability.
SEE ALSO
Langertha::Stream - Iterator that holds chunks
Langertha::Response - Non-streaming response object
Langertha::Role::Chat - Chat role that produces streams
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.