Skip to main content

Module responses

Module responses 

Source
Expand description

The Responses API: create model responses and retrieve stored ones.

The Responses API is the successor of the Chat Completions API. Instead of messages it takes an input that is either a plain string or a list of input items (message, function_call, function_call_output, reasoning, …), and instead of choices it returns a list of output items.

Request types live in create::request, the shared response object and the streaming event types in this module and create, and the retrieve endpoint in retrieve.

Provider support is partial — see the DeepSeek Responses API guide and the Qwen Responses API reference. Notably DeepSeek’s implementation is stateless (store, previous_response_id and retrieval are not supported there), while Qwen supports multi-turn conversations via previous_response_id.

§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()),
        ..Default::default()
    };

    let response = request
        .get_response(&default_client(), DEEPSEEK_URL, &RequestOptions::bearer("YOUR_API_KEY"))
        .await?;
    println!("{}", response.output_text());
    Ok(())
}

Modules§

cancel
Cancel a background response via POST /responses/{response_id}/cancel.
create
Create a response via POST /responses.
delete
Delete a stored response via DELETE /responses/{response_id}.
input_items
List the input items of a stored response via GET /responses/{response_id}/input_items.
retrieve
Retrieve a stored response via GET /responses/{response_id}.

Structs§

CodeInterpreterCall
Qwen: a code interpreter tool call.
FileSearchCall
Qwen: a knowledge-base (file search) tool call.
ImageSearchCall
Qwen: an image-to-image search tool call.
IncompleteDetails
Details about why the response is incomplete.
InputTokensDetails
A breakdown of the input tokens.
McpCall
Qwen: a call to a tool on an MCP server.
OutputTokensDetails
A breakdown of the output tokens.
ReasoningSummary
A summary part of a ResponseReasoningItem.
Response
The response object returned by the Responses API (non-streaming create, the final streaming events, and retrieve).
ResponseError
An error object returned when the model fails to generate a response.
ResponseFunctionCall
A call to a user-defined function.
ResponseOutputMessage
A message output from the model.
ResponseReasoningItem
A reasoning item (chain-of-thought and/or summaries) from the model.
ResponseUsage
Token usage statistics of a Response.
ResponseWebSearchCall
A web search performed by the server-side web search tool.
WebExtractorCall
Qwen: a web page extraction tool call.
WebSearchAction
The search action of a ResponseWebSearchCall.
WebSearchImageCall
Qwen: a text-to-image search tool call.
WebSearchSource
A source cited by a web search.

Enums§

Annotation
An annotation on an output text part.
IncompleteReason
Why a response is incomplete.
ItemStatus
The status of an output item.
OutputContent
A content part of an output ResponseOutputMessage.
ReasoningContent
A content part of a ResponseReasoningItem.
ResponseObject
The object field of a response object, always response.
ResponseOutputItem
An item in the output array of a Response.
ResponseStatus
The status of the response generation.