Skip to main content

CompletionRequest

Struct CompletionRequest 

Source
pub struct CompletionRequest {
    pub model: Model,
    pub messages: Vec<Message>,
    pub tools: Vec<ToolDefinition>,
    pub max_tokens: Option<u32>,
    pub reasoning: ReasoningLevel,
    pub sampling: SamplingParams,
    pub modalities: Vec<Modality>,
    pub audio_config: Option<AudioOutputConfig>,
    pub image_config: Option<ImageGenConfig>,
    pub user: Option<String>,
    pub provider_preferences: Option<ProviderPreferences>,
    pub session_id: Option<SessionId>,
}
Expand description

A single completion request sent to an LLM provider.

This is the primary input type for LlmProvider::complete. The agent runtime assembles this from the conversation history, active tools, and LLM config.

Fields§

§model: Model

Model to use (includes provider prefix).

§messages: Vec<Message>

Message history in wire format.

§tools: Vec<ToolDefinition>

Tools available to the model in this turn.

§max_tokens: Option<u32>

Maximum output tokens. If None, the provider decides.

§reasoning: ReasoningLevel

Whether reasoning/thinking mode is enabled.

§sampling: SamplingParams

Sampling parameters (temperature, top_p, top_k, min_p, penalties).

§modalities: Vec<Modality>

Output modalities (e.g. text+audio, image). Empty means text-only.

§audio_config: Option<AudioOutputConfig>

Audio output configuration. Only used when modalities includes Modality::Audio.

§image_config: Option<ImageGenConfig>

Image generation configuration. Only used when modalities includes Modality::Image.

§user: Option<String>

Opaque user identifier for per-user tracking in provider dashboards.

§provider_preferences: Option<ProviderPreferences>

Provider routing preferences (used by OpenRouter).

§session_id: Option<SessionId>

Stable conversation identifier for provider cache routing.

Implementations§

Source§

impl CompletionRequest

Source

pub fn new(model: Model, messages: Vec<Message>) -> Self

Build a request with default settings and the supplied messages.

Source

pub fn from_config(config: &AgentLlmConfig, messages: Vec<Message>) -> Self

Keep the agent’s session ID, routing, user and generation settings.

use flashmind_types::{AgentLlmConfig, CompletionRequest, Message, SessionId};

let session = SessionId::new();
let llm = AgentLlmConfig::new("openrouter:example/model".parse()?)
    .with_session_id(session);
let request = CompletionRequest::from_config(&llm, vec![Message::user("Hello")]);
assert_eq!(request.session_id, llm.session_id);
Source

pub fn with_session_id(self, session_id: impl Into<SessionId>) -> Self

Use an existing session identity for this request.

Trait Implementations§

Source§

impl Debug for CompletionRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more