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§
- OpenAI
Chat Client - 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-levelinstructionsfield, returning the remaining messages to convert intoinputitems. - messages_
to_ input - Convert framework messages into the Responses API’s
inputitem array. - parse_
response pubsoagent-framework-azure’s Responses client (whose wire format is otherwise identical) can reuse this parser — includingparse_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_formatinto a Responses APItext.formatobject. Unlike Chat Completions (which nests the schema underjson_schema), the Responses API uses a flat object. - tool_
choice_ to_ responses pubsoagent-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.