Documentation
¶
Overview ¶
Package responses serves the OpenAI Responses API as a text-only endpoint.
It is the third frontend, alongside openai (Chat Completions) and anthropic (Messages), and reads the same ir the other two do: no adapter knows this package exists.
Two things about the dialect shape what is here. The Responses API is stateful by design — a client may send only the new turn and name the prior response with previous_response_id — and agent2api keeps no state, so that field is refused rather than approximated. And its output is a list of items rather than one message, which is where reasoning goes: its own item, ahead of the message, instead of a block inside it.
Index ¶
Constants ¶
const MaxRequestBytes = 32 << 20 // 32 MiB
MaxRequestBytes caps the request body. A replayed conversation is the payload here, so the limit is generous, but not unbounded.
Variables ¶
This section is empty.
Functions ¶
func WriteError ¶
func WriteError(w http.ResponseWriter, err error)
WriteError renders err in OpenAI's error shape with the matching status.
The mapping is a copy of the openai frontend's rather than a shared helper: the two dialects agree today, and a frontend that imports another frontend to save twenty lines is a worse trade than the duplication. TestErrorShape pins them together.
Types ¶
type Handler ¶
type Handler struct {
Router *router.Router
Log *slog.Logger
// Heartbeat is how often a silent stream emits a keepalive comment. Zero
// disables keepalives; [New] starts it at [sse.DefaultHeartbeat].
Heartbeat time.Duration
// Now is injectable so tests get stable timestamps.
Now func() time.Time
}
Handler serves the Responses endpoint.