Documentation
¶
Overview ¶
Package codex is a glue.Provider that routes through the Codex Responses endpoint at chatgpt.com/backend-api/codex/responses, authenticated with a ChatGPT subscription via OAuth tokens read from the upstream Codex CLI's auth.json (run "codex login" once outside glue).
Design: docs/adr/0006-codex-provider.md. Token handling lives in providers/codex/auth; this package owns request construction, the SSE event stream, and the 401-refresh-retry loop.
Index ¶
Constants ¶
const DefaultBaseURL = "https://chatgpt.com/backend-api/codex"
DefaultBaseURL is the Codex Responses endpoint root used when Options.BaseURL is empty.
const DefaultModel = "gpt-5-codex"
DefaultModel is the registry-level default model id for the codex provider. Callers typically override per-request via glue.WithModel.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Model is the registry-level default model when ProviderRequest.Model
// is empty. Empty falls back to DefaultModel.
Model string
// BaseURL overrides the Codex Responses root. Empty falls back to
// DefaultBaseURL. Tests inject an httptest URL here.
BaseURL string
// HTTPClient is used for the Responses POST. A cookie jar scoped
// to the chatgpt.com host is installed automatically when this is
// nil; supply your own client to take ownership.
HTTPClient *http.Client
// OriginatorOverride replaces the "originator" header (default
// "codex_cli_rs"). Server-side allowlist may reject other values.
OriginatorOverride string
// Auth is the token manager. When nil a default auth.Manager is
// constructed; AuthFile is applied to it when non-empty.
Auth *auth.Manager
// AuthFile sets Auth.PathOverride. Convenient for tests that don't
// want to construct a Manager directly.
AuthFile string
}
Options configures the codex provider. All fields are optional.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements loop.Provider against the Codex Responses endpoint. Construct via New.
func New ¶
New constructs a Provider. Required fields are validated lazily in Stream so that the constructor never returns an error.
func (*Provider) Stream ¶
func (p *Provider) Stream(ctx context.Context, req loop.ProviderRequest) (<-chan loop.ProviderEvent, error)
Stream implements loop.Provider. See ADR-0006 §3 for the request and SSE shapes.