responses

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2026 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

func New

func New(r *router.Router, log *slog.Logger) *Handler

New builds a handler.

func (*Handler) Responses

func (h *Handler) Responses(w http.ResponseWriter, r *http.Request)

Responses implements POST /v1/responses.

func (*Handler) Routes

func (h *Handler) Routes(mux *http.ServeMux)

Routes registers the Responses endpoints on mux.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL