Documentation
¶
Overview ¶
Package codexauth signs a codeaf profile in to a ChatGPT plan in the same way the Codex CLI does, and adapts that plan's Responses API for codeaf's provider client. OpenAI's terms for a ChatGPT plan apply to work run on it.
Index ¶
- Constants
- Variables
- func Backend() string
- func Client(profileDir string) *http.Client
- func ClientWithOptions(profileDir string, options Options) *http.Client
- func Connected(profileDir string) bool
- func Issuer() string
- func ModelsPath(profileDir string) string
- func Path(profileDir string) string
- func Remove(profileDir string) error
- func Save(profileDir string, tokens Tokens) error
- func Translate(profileDir string, options Options) http.RoundTripper
- type Flow
- type Model
- type Options
- type Tokens
Constants ¶
const ( DefaultIssuer = "https://auth.openai.com" DefaultBackend = "https://chatgpt.com/backend-api/codex" ClientID = "app_EMoamEEZ73f0CkXaXp7hrann" Sentinel = "chatgpt" Originator = "codex_cli_rs" )
const FallbackContextWindow = 272000
FallbackContextWindow is the window the account's own model list gave every visible model when it was last observed (2026-09-21, a Pro account: `"context_window": 272000` on each row). It is ONE figure because the fallback rows below are one observation, and a row that carried no window would leave a conversation that moved onto it compacting at its previous model's figure.
const QuotaWords = "codex reached your chatgpt plan's usage limit · it resets on its own"
QuotaWords is the person-facing outcome for a ChatGPT plan window that has been spent. The plan owns its reset, so there is no billing action to offer.
Variables ¶
var ErrSignInExpired error = &signInExpiredError{}
ErrSignInExpired is the one actionable sentence returned when the issuer no longer accepts a profile's rotating refresh token.
var FallbackModels = []Model{ {ID: "gpt-5.5", ContextLength: FallbackContextWindow}, {ID: "gpt-5.6-sol", ContextLength: FallbackContextWindow}, {ID: "gpt-5.6-terra", ContextLength: FallbackContextWindow}, {ID: "gpt-5.6-luna", ContextLength: FallbackContextWindow}, }
FallbackModels is the last observed public list used when a fresh account listing cannot be reached during connection.
Functions ¶
func Backend ¶
func Backend() string
Backend returns the configured ChatGPT backend used by both listing and turns.
func ClientWithOptions ¶
ClientWithOptions returns the same client with deterministic test edges.
func Issuer ¶
func Issuer() string
Issuer returns the configured issuer without changing the fixed callback.
func ModelsPath ¶
ModelsPath names the non-secret listing cached beside the tokens.
Types ¶
type Flow ¶
type Flow struct {
// contains filtered or unexported fields
}
Flow is one browser connection whose fixed loopback listener is already standing when Begin returns.
func Begin ¶
Begin starts the exact S256 loopback flow registered for the Codex CLI, trying its primary port and then its one fallback.
type Model ¶
type Model struct {
ID string `json:"id"`
// ContextLength is the listing's own `context_window`, zero when the row
// carried none. It is what the session compacts against and what the status
// line's meter is a share of, so a Codex model that dropped it kept whatever
// window the conversation's previous model had (#1383).
ContextLength int `json:"context_length,omitempty"`
ReasoningLevels []string `json:"reasoning_levels,omitempty"`
}
Model is one model the signed-in account may choose, with how many tokens it accepts and the reasoning levels the request translator is allowed to send for it.
type Options ¶
type Options struct {
Issuer string
Backend string
HTTPClient *http.Client
Random io.Reader
Listen func(network, address string) (net.Listener, error)
Now func() time.Time
SessionID string
}
Options holds every replaceable edge of a Codex browser sign-in and its later backend calls. The zero value is the shipped service.
type Tokens ¶
type Tokens struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
IDToken string `json:"id_token"`
AccountID string `json:"account_id"`
Email string `json:"email"`
Plan string `json:"plan"`
ExpiresAt time.Time `json:"expires_at"`
LastRefresh time.Time `json:"last_refresh"`
}
Tokens is the complete durable answer from one browser sign-in.