Skip to main content

Crate chat_responses

Crate chat_responses 

Source
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§

ChatFailure
ReasoningConfig
Request
An outbound request to be sent by a transport.
ReqwestTransport
HTTP transport backed by reqwest.
Response
The response returned by a transport for a unary (non-streaming) call.
ResponsesApiResponse
ResponsesBuilder
ResponsesClient
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.
ResponsesErrorDetail
ResponsesErrorResponse
ResponsesFunctionCall
ResponsesImageGenerationCall
ResponsesMessage
ResponsesReasoning
ResponsesRequest
ResponsesRequestConfig
ResponsesUsage
ResponsesWebSearchCall
WithModel
WithUrl
WithoutModel
WithoutUrl

Enums§

ChatError
ResponsesContentPart
ResponsesOutputItem
ResponsesSummaryPart
TransportError

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.