Skip to main content

Module request

Module request 

Source
Expand description

Unified request layer.

Request is the self-contained, provider-agnostic chat-completion request. It carries everything needed to hit an LLM API — provider, credentials, model, messages, tools, and tuning knobs.

use agentix::{Request, Provider, Message, UserContent, LlmEvent};
use futures::StreamExt;

let http = reqwest::Client::new();

let mut stream = Request::new(Provider::DeepSeek, "sk-...")
    .model("deepseek-chat")
    .system_prompt("You are helpful.")
    .user("Hello!")
    .stream(&http)
    .await?;

while let Some(event) = stream.next().await {
    if let LlmEvent::Token(t) = event { print!("{t}"); }
}

Structs§

ImageContent
Image content that can be embedded in a user message.
Request
A self-contained, provider-agnostic chat-completion request.
ToolCall
A single tool invocation requested by the model.

Enums§

ImageData
How the image data is provided.
Message
A single turn in a conversation. Every variant carries exactly the fields it needs — no invalid states are representable.
Provider
Which LLM provider to use.
ResponseFormat
Provider-agnostic output-format hint.
ToolChoice
Provider-agnostic tool selection hint.
UserContent
A single content block inside a Message::User.

Functions§

truncate_to_token_budget
Drop the oldest messages from history until the total estimated token count is at or below budget. Always keeps at least one message.