codex

package
v2026.1024.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 28 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

Index

Constants

View Source
const (
	AuthorizeURL = "https://auth.openai.com/oauth/authorize"
	TokenURL     = "https://auth.openai.com/oauth/token"
	ClientID     = "app_EMoamEEZ73f0CkXaXp7hrann"
	RedirectURI  = "http://localhost:1455/auth/callback"
	Scopes       = "openid profile email offline_access api.connectors.read api.connectors.invoke"
	Originator   = "codex_cli_rs"
	// ClientVersion is the offline fallback; requests resolve npm latest dynamically.
	ClientVersion = "0.163.0"
	CallbackAddr  = "127.0.0.1:1455"
	CallbackPath  = "/auth/callback"
)

Variables

View Source
var (
	ChatGPTSubAPIBase   = "https://chatgpt.com/backend-api/codex"
	ChatGPTResponsesURL = "https://chatgpt.com/backend-api/codex/responses"
)
View Source
var CodexVersionRegistryURL = "https://registry.npmjs.org/@openai%2Fcodex/latest"

CodexVersionRegistryURL returns metadata for npm's stable latest tag.

Functions

func BuildAuthorizeURL

func BuildAuthorizeURL(pkce PKCE) string

func ChatGPTAccountIDFromJWT

func ChatGPTAccountIDFromJWT(token string) string

func ListModels added in v2026.716.0

func ListModels(ctx context.Context, bearer, accountID string) ([]string, error)

func ModelInputModalities added in v2026.1020.0

func ModelInputModalities(id string) []string

func ResolveClientVersion added in v2026.909.0

func ResolveClientVersion(ctx context.Context, force bool) string

ResolveClientVersion checks npm at most once per six hours, unless forced. Registry failures preserve the cached version, or the built-in fallback on first use, and are retried after five minutes. No OAuth credentials go to npm.

func SetTokenEndpointForTest added in v2026.1019.1

func SetTokenEndpointForTest(endpoint string) func()

func WithChatGPTSubMiddleware

func WithChatGPTSubMiddleware(accountID string) option.RequestOption

Types

type PKCE

type PKCE struct {
	Verifier  string
	Challenge string
	State     string
}

func NewPKCE

func NewPKCE() (PKCE, error)

type TokenSet

type TokenSet struct {
	AccessToken  string
	RefreshToken string
	AccountID    string
	ExpiresAt    time.Time
}

func Login

func Login(ctx context.Context, out io.Writer) (TokenSet, error)

Login keeps the browser -> authorization -> localhost redirect experience. Each attempt owns its listener and state; a retry closes the prior attempt.

func LoginWithBrowser added in v2026.1019.1

func LoginWithBrowser(ctx context.Context, out io.Writer, browser func(string) error) (TokenSet, error)

LoginWithBrowser allows desktop hosts to supply their own browser launcher.

func Refresh

func Refresh(ctx context.Context, refreshToken string) (TokenSet, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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