Documentation
¶
Overview ¶
Package anthropic implements the Anthropic-compatible HTTP surface: POST /v1/messages, streaming and non-streaming.
The wire shapes below are the subset of the Messages API that agent2api can honour, plus the fields it must explicitly refuse. Everything an agent CLI cannot enforce is either passed along as a best-effort hint or rejected with a 400 — never silently ignored in a way that changes the answer.
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 Anthropic's error shape with the matching status.
Types ¶
type Handler ¶
type Handler struct {
Router *router.Router
Log *slog.Logger
// Heartbeat is how often a silent stream emits a ping. Zero disables
// pings; [New] starts it at [sse.DefaultHeartbeat].
Heartbeat time.Duration
// Now is injectable so tests get stable timestamps.
Now func() time.Time
}
Handler serves the Anthropic-compatible endpoints.