Skip to main content

ResponseCreateRequest

Struct ResponseCreateRequest 

Source
pub struct ResponseCreateRequest {
Show 22 fields pub model: String, pub input: Option<ResponseInput>, pub instructions: Option<String>, pub tools: Option<Vec<ResponseTool>>, pub tool_choice: Option<ResponseToolChoice>, pub parallel_tool_calls: Option<bool>, pub previous_response_id: Option<String>, pub temperature: Option<f64>, pub top_p: Option<f64>, pub max_output_tokens: Option<i64>, pub truncation: Option<String>, pub reasoning: Option<Reasoning>, pub store: Option<bool>, pub metadata: Option<HashMap<String, String>>, pub include: Option<Vec<String>>, pub stream: Option<bool>, pub service_tier: Option<String>, pub user: Option<String>, pub text: Option<ResponseTextConfig>, pub prompt_cache_key: Option<String>, pub prompt_cache_retention: Option<String>, pub background: Option<bool>,
}
Expand description

Request body for POST /responses.

Fields§

§model: String

Model to use.

§input: Option<ResponseInput>

Input text or messages.

§instructions: Option<String>

System instructions.

§tools: Option<Vec<ResponseTool>>

Tools available to the model.

§tool_choice: Option<ResponseToolChoice>

How the model selects tools.

§parallel_tool_calls: Option<bool>

Whether to enable parallel tool calls.

§previous_response_id: Option<String>

Previous response ID for multi-turn.

§temperature: Option<f64>

Temperature (0-2).

§top_p: Option<f64>

Nucleus sampling parameter.

§max_output_tokens: Option<i64>

Max output tokens.

§truncation: Option<String>

Truncation strategy: “auto” or “disabled”.

§reasoning: Option<Reasoning>

Reasoning configuration for o-series models.

§store: Option<bool>

Store for evals/distillation.

§metadata: Option<HashMap<String, String>>

Metadata key-value pairs.

§include: Option<Vec<String>>

Additional data to include in response.

§stream: Option<bool>

Whether to stream.

§service_tier: Option<String>

Service tier.

§user: Option<String>

End user identifier.

§text: Option<ResponseTextConfig>

Text output configuration.

§prompt_cache_key: Option<String>

Prompt cache key — caches system prompt prefix server-side for faster repeat calls.

§prompt_cache_retention: Option<String>

Prompt cache retention: “in-memory” or “24h” for extended caching.

§background: Option<bool>

Whether to run in background mode.

Implementations§

Source§

impl ResponseCreateRequest

Source

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

Create a new request with the given model.

Source

pub fn input(self, input: impl Into<ResponseInput>) -> Self

Set the input text or messages.

Source

pub fn instructions(self, instructions: impl Into<String>) -> Self

Set system instructions.

Source

pub fn tools(self, tools: Vec<ResponseTool>) -> Self

Set the tools.

Source

pub fn tool_choice(self, choice: ResponseToolChoice) -> Self

Set how the model selects tools.

Source

pub fn previous_response_id(self, id: impl Into<String>) -> Self

Set previous response ID for multi-turn.

Source

pub fn temperature(self, temperature: f64) -> Self

Set the temperature (0-2).

Source

pub fn max_output_tokens(self, max: i64) -> Self

Set max output tokens.

Source

pub fn reasoning(self, reasoning: Reasoning) -> Self

Set reasoning configuration.

Source

pub fn truncation(self, truncation: impl Into<String>) -> Self

Set truncation strategy.

Source

pub fn store(self, store: bool) -> Self

Enable storage for evals/distillation.

Source

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

Set model.

Source

pub fn text(self, text: ResponseTextConfig) -> Self

Set text output configuration (format + verbosity).

Source

pub fn top_p(self, top_p: f64) -> Self

Set top_p (nucleus sampling).

Source

pub fn parallel_tool_calls(self, parallel: bool) -> Self

Enable or disable parallel tool calls.

Source

pub fn metadata(self, metadata: HashMap<String, String>) -> Self

Set metadata key-value pairs.

Source

pub fn include(self, include: Vec<String>) -> Self

Set include fields for additional response data.

Source

pub fn service_tier(self, tier: impl Into<String>) -> Self

Set service tier (“auto”, “default”, “flex”, “scale”, “priority”).

Source

pub fn user(self, user: impl Into<String>) -> Self

Set end user identifier.

Source

pub fn prompt_cache_key(self, key: impl Into<String>) -> Self

Set prompt cache key for server-side system prompt caching.

Source

pub fn prompt_cache_retention(self, retention: impl Into<String>) -> Self

Set prompt cache retention: “in-memory” or “24h”.

Source

pub fn background(self, background: bool) -> Self

Run response in background mode.

Trait Implementations§

Source§

impl Clone for ResponseCreateRequest

Source§

fn clone(&self) -> ResponseCreateRequest

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 ResponseCreateRequest

Source§

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

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

impl Default for ResponseCreateRequest

Source§

fn default() -> ResponseCreateRequest

Returns the “default value” for a type. Read more
Source§

impl Serialize for ResponseCreateRequest

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> 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.