pub struct RequestBody {Show 27 fields
pub background: Option<bool>,
pub conversation: Option<String>,
pub include: Option<Vec<String>>,
pub input: Input,
pub instructions: Option<String>,
pub max_output_tokens: Option<u32>,
pub max_tool_calls: Option<u32>,
pub metadata: Option<HashMap<String, String>>,
pub model: String,
pub parallel_tool_calls: Option<bool>,
pub previous_response_id: Option<String>,
pub prompt_cache_key: Option<String>,
pub enable_thinking: Option<bool>,
pub reasoning: Option<ReasoningConfig>,
pub safety_identifier: Option<String>,
pub service_tier: Option<ServiceTier>,
pub store: Option<bool>,
pub stream: Option<bool>,
pub temperature: Option<f32>,
pub text: Option<TextConfig>,
pub tool_choice: Option<ToolChoice>,
pub tools: Option<Vec<Tool>>,
pub top_logprobs: Option<u32>,
pub top_p: Option<f32>,
pub truncation: Option<Truncation>,
pub user: Option<String>,
pub extra_body_map: Option<Map<String, Value>>,
}Expand description
Creates a model response for the given input.
§Example
use openai_interface::responses::create::request::{Input, RequestBody};
use openai_interface::rest::{default_client, post::PostNoStream, RequestOptions};
const DEEPSEEK_URL: &'static str = "https://api.deepseek.com";
const DEEPSEEK_MODEL: &'static str = "deepseek-v4-flash";
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Needs the `ferritls` cargo feature; drop this line if you install
// your own rustls crypto provider (see `openai_interface::rest`).
openai_interface::rest::install_crypto_provider().ok();
let request = RequestBody {
model: DEEPSEEK_MODEL.to_string(),
input: Input::Text("Hello!".to_string()),
instructions: Some("You are a helpful assistant.".to_string()),
..Default::default()
};
let response = request
.get_response(&default_client(), DEEPSEEK_URL, &RequestOptions::bearer("YOUR_API_KEY"))
.await?;
println!("{}", response.output_text());
Ok(())
}Fields§
§background: Option<bool>Whether to run the model response in the background, returning a queued response immediately. Not supported by DeepSeek and Qwen (synchronous calls only).
conversation: Option<String>The ID of an existing conversation to prepend to the input. Items
from this response are automatically added to the conversation after
it completes. Mutually exclusive with previous_response_id.
Not supported by DeepSeek (stateless API).
include: Option<Vec<String>>Additional output data to include in the model response, e.g.
"message.output_text.logprobs" or "reasoning.encrypted_content".
input: InputText, image, or file inputs to the model, used to generate a
response. Either a plain string (treated as one user message) or
a list of input items. Together with Self::instructions, at
least one must be provided.
instructions: Option<String>A system (or developer) message inserted into the model’s context.
When used along with previous_response_id, the instructions from a
previous response are not carried over.
max_output_tokens: Option<u32>An upper bound for the number of tokens that can be generated for a response, including visible output tokens and reasoning tokens.
max_tool_calls: Option<u32>The maximum number of total calls to built-in tools that can be processed in a response.
metadata: Option<HashMap<String, String>>Set of 16 key-value pairs that can be attached to an object. Keys are strings with a maximum length of 64 characters; values are strings with a maximum length of 512 characters. Not supported by DeepSeek.
model: StringModel ID used to generate the response, e.g. deepseek-v4-flash or
qwen3.8-max.
parallel_tool_calls: Option<bool>Whether to allow the model to run tool calls in parallel. Ignored by DeepSeek (parallel tool calls are always enabled).
previous_response_id: Option<String>The unique ID of the previous response to the model. Use this to
create multi-turn conversations without resending the full input
history. Mutually exclusive with conversation. Not supported by
DeepSeek (stateless API); supported by Qwen.
prompt_cache_key: Option<String>Used by OpenAI to cache responses for similar requests to optimize
cache hit rates. Replaces the user field. Not supported by
DeepSeek (caching is automatic there).
enable_thinking: Option<bool>Qwen: whether to enable thinking mode for hybrid-thinking models.
The thinking content is returned via reasoning output items.
Non-standard parameter; reasoning.effort is preferred.
reasoning: Option<ReasoningConfig>Configuration options for reasoning models.
safety_identifier: Option<String>A stable identifier used to help detect users of your application that may be violating the usage policies.
service_tier: Option<ServiceTier>Specifies the processing type used for serving the request. Not supported by DeepSeek.
store: Option<bool>Whether to store the generated model response for later retrieval via the retrieve endpoint. DeepSeek always stores nothing (its Responses API is stateless).
stream: Option<bool>If set to true, the response is streamed back as semantic
server-sent events (see super::response::ResponseStreamEvent).
temperature: Option<f32>What sampling temperature to use, between 0 and 2. Higher values make the output more random. Has no effect in thinking mode.
text: Option<TextConfig>Configuration options for a text response from the model: plain text or structured JSON data.
tool_choice: Option<ToolChoice>How the model should select which tool (or tools) to use when generating a response.
tools: Option<Vec<Tool>>An array of tools the model may call while generating a response.
top_logprobs: Option<u32>An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability.
top_p: Option<f32>An alternative to sampling with temperature, called nucleus sampling. Has no effect in thinking mode.
truncation: Option<Truncation>The truncation strategy to use for the model response. DeepSeek
only supports disabled (over-long inputs return an error).
user: Option<String>A stable identifier for your end-users. Being replaced by
safety_identifier and prompt_cache_key.
extra_body_map: Option<Map<String, Value>>Other request body fields that are not covered above. Useful for
provider-specific parameters such as Qwen’s ocr_options.
Implementations§
Source§impl RequestBody
impl RequestBody
Sourcepub fn is_streaming(&self) -> bool
pub fn is_streaming(&self) -> bool
Whether this request asks for a streamed response. Defaults to
false when RequestBody::stream is None.
Trait Implementations§
Source§impl Clone for RequestBody
impl Clone for RequestBody
Source§fn clone(&self) -> RequestBody
fn clone(&self) -> RequestBody
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RequestBody
impl Debug for RequestBody
Source§impl Default for RequestBody
impl Default for RequestBody
Source§fn default() -> RequestBody
fn default() -> RequestBody
Source§impl<'de> Deserialize<'de> for RequestBody
impl<'de> Deserialize<'de> for RequestBody
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Post for RequestBody
impl Post for RequestBody
Source§impl PostNoStream for RequestBody
impl PostNoStream for RequestBody
Source§impl PostStream for RequestBody
impl PostStream for RequestBody
type Response = ResponseStreamEvent
Source§fn get_stream_response_string(
&self,
client: &Client,
base_url: &str,
options: &RequestOptions,
) -> impl Future<Output = Result<impl Stream<Item = Result<String, OapiError>> + Send + Unpin + 'static, OapiError>> + Send + Sync
fn get_stream_response_string( &self, client: &Client, base_url: &str, options: &RequestOptions, ) -> impl Future<Output = Result<impl Stream<Item = Result<String, OapiError>> + Send + Unpin + 'static, OapiError>> + Send + Sync
Source§fn get_stream_response(
&self,
client: &Client,
base_url: &str,
options: &RequestOptions,
) -> impl Future<Output = Result<impl Stream<Item = Result<Self::Response, OapiError>> + Send + Unpin + 'static, OapiError>> + Send + Sync
fn get_stream_response( &self, client: &Client, base_url: &str, options: &RequestOptions, ) -> impl Future<Output = Result<impl Stream<Item = Result<Self::Response, OapiError>> + Send + Unpin + 'static, OapiError>> + Send + Sync
Self::Response. Read more