Documentation
¶
Overview ¶
Package httpx provides HTTP utilities for model providers. It includes retry logic with exponential backoff, Retry-After support, and context cancellation handling.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an HTTP client with built-in retry logic and backoff. It rebuilds request bodies to support retries on idempotent failures.
func NewClient ¶
NewClient creates a new HTTP client with optional base client. If base is nil, http.DefaultClient is used.
func (*Client) Do ¶
Do executes an HTTP request with automatic retry on 429 and 5xx errors. It uses exponential backoff with jitter and honors the Retry-After header. The request body must be rebuildable via req.GetBody or provided as bytes. Returns the response or an error wrapping context.Canceled if the context is canceled.
type SSEEvent ¶
type SSEEvent struct {
// Event is the event type (optional).
Event string
// Data is the event data payload (may be empty).
Data string
// ID is the event ID (optional).
ID string
}
SSEEvent represents a single Server-Sent Event.
type SSEReader ¶
type SSEReader struct {
// contains filtered or unexported fields
}
SSEReader reads Server-Sent Events from an io.Reader. It skips comments (lines starting with :) and handles multi-line data.
func NewSSEReader ¶
NewSSEReader creates a new SSE reader from an io.Reader.