Skip to main content

Module responses

Module responses 

Source
Expand description

OpenAIChatClient: a ChatClient for the OpenAI Responses API (POST /v1/responses).

The Responses API uses an item-based input/output shape rather than the messages array used by Chat Completions, and supports a dedicated previous_response_id for service-side conversation state. Wire framing (SSE parsing style, error handling) mirrors crate::OpenAIChatCompletionClient.

use agent_framework_openai::responses::OpenAIChatClient;
use agent_framework_core::prelude::*;

let client = OpenAIChatClient::new("sk-...", "gpt-4o-mini");
let agent = Agent::builder(client)
    .instructions("You are concise.")
    .build();
let reply = agent.run_once("Say hi").await?;
println!("{}", reply.text());

Structs§

OpenAIChatClient
An OpenAI Responses API chat client (POST /v1/responses).

Functions§

extract_instructions
Split a leading system message (and/or ChatOptions::instructions) out into the Responses API’s top-level instructions field, returning the remaining messages to convert into input items.
messages_to_input
Convert framework messages into the Responses API’s input item array.
parse_response
pub so agent-framework-azure’s Responses client (whose wire format is otherwise identical) can reuse this parser — including parse_output_item, parse_annotations, and usage/finish-reason handling — rather than reimplementing it.
parse_responses_sse_stream
Turn a Responses API SSE HTTP response into a stream of updates.
response_failure_error
Parse a full (non-streaming) Responses API response.
response_format_to_text
Convert a ChatOptions::response_format into a Responses API text.format object. Unlike Chat Completions (which nests the schema under json_schema), the Responses API uses a flat object.
tool_choice_to_responses
pub so agent-framework-azure’s Responses client can reuse this mapping rather than reimplementing it.
tool_to_responses_spec
The flat Responses-API tool spec: {"type":"function","name":...}, unlike Chat Completions’ {"type":"function","function":{...}} nesting.