Expand description
Generic OpenAI Responses API client.
Targets the /responses endpoint and its SSE event stream
(response.created, response.output_text.delta, etc.). This crate
owns the wire types — provider crates that ship a Responses-API
surface (today: chat-openai; planned: chat-groq’s Responses
path) wrap ResponsesBuilder and preset URL + auth + any
provider-specific tool declarations.
Provider-specific native tools (OpenAI’s web_search,
image_generation, etc.) are passed in as pre-materialized
Values via ResponsesBuilder::with_tool_declaration. The
wrapper owns the tool trait; this crate stays trait-agnostic.
use chat_responses::ResponsesBuilder;
let client = ResponsesBuilder::new()
.with_base_url("https://api.openai.com/v1")
.with_model("gpt-4o")
.with_api_key("sk-...")
.build();Structs§
- Chat
Failure - Reasoning
Config - Request
- An outbound request to be sent by a transport.
- Reqwest
Transport - HTTP transport backed by
reqwest. - Response
- The response returned by a transport for a unary (non-streaming) call.
- Responses
ApiResponse - Responses
Builder - Responses
Client - Generic client over the OpenAI Responses API wire format
(
POST {base_url}/responses). Provider wrappers like [chat_openai] hold one of these as their inner state. - Responses
Error Detail - Responses
Error Response - Responses
Function Call - Responses
Image Generation Call - Responses
Message - Responses
Reasoning - Responses
Request - Responses
Request Config - Responses
Usage - Responses
WebSearch Call - With
Model - WithUrl
- Without
Model - Without
Url
Enums§
Traits§
- Transport
- A pluggable transport layer for sending requests and receiving responses or event streams.
Functions§
- handle_
responses_ error - Maps a raw transport response into a
ChatFailure. Recognises the{ "error": { "code", "message", "status" } }envelope used by OpenAI and the providers (Groq, future) that adopt the Responses wire — same shape as the Chat Completions envelope. - output_
items_ to_ parts - Converts a slice of Responses API output items into core parts. Returns the parts and whether any function calls were present.