Skip to main content

CompletionRequest

Struct CompletionRequest 

Source
#[non_exhaustive]
pub struct CompletionRequest { pub model: String, pub system: Option<String>, pub messages: Vec<Message>, pub tools: Vec<ToolSpec>, pub tool_choice: ToolChoice, pub response_format: Option<JsonSchema>, pub max_tokens: Option<u32>, pub temperature: Option<f32>, pub stop: Vec<String>, pub web_search: bool, }
Expand description

Top-level request to an LLM provider.

Construct via CompletionRequest::new, then populate fields directly.

#[non_exhaustive]: provider-shaped sampling fields (top_p, seed, …) will be added over time; build through new so such additions stay non-breaking.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§model: String

The model identifier (e.g. "fast-2", "reasoning-pro").

§system: Option<String>

Optional system prompt text prepended before the conversation.

§messages: Vec<Message>

Ordered list of messages in the conversation.

§tools: Vec<ToolSpec>

Tool definitions available to the model.

§tool_choice: ToolChoice

How the model should decide whether to call a tool.

§response_format: Option<JsonSchema>

When set, instructs the provider to return structured JSON output.

§max_tokens: Option<u32>

Maximum number of tokens the model may generate.

§temperature: Option<f32>

Sampling temperature in [0.0, 2.0]. Lower is more deterministic.

§stop: Vec<String>

Token sequences that cause the model to stop generating.

§web_search: bool

When true, the model may search the public web to ground its answer.

This is a provider-agnostic capability hint: a provider maps it to its native mechanism (Vertex Gemini → the googleSearch grounding tool, alongside any tools function declarations) and a provider without web search ignores it. Defaults to false; the agent’s answering loop (run_turn) sets it from its RunTurnOptions.web_search, so auxiliary calls (summarization, classification) that bypass that loop never offer search.

Implementations§

Source§

impl CompletionRequest

Source

pub fn new(model: impl Into<String>) -> Self

Creates a new request for the given model with sensible defaults: empty messages, tools, and stop lists; tool_choice set to ToolChoice::Auto; all optional fields None.

Trait Implementations§

Source§

impl Clone for CompletionRequest

Source§

fn clone(&self) -> CompletionRequest

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CompletionRequest

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for CompletionRequest

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for CompletionRequest

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.