Documentation
¶
Index ¶
- Constants
- type Account
- type DeviceCodeResponse
- type DeviceTokenPollResponse
- type Provider
- func (p *Provider) Accounts() []*Account
- func (p *Provider) ChatCompletion(ctx context.Context, req *providers.ChatRequest) (io.ReadCloser, bool, int, error)
- func (p *Provider) Embeddings(ctx context.Context, req *providers.EmbeddingRequest) (*providers.EmbeddingResponse, error)
- func (p *Provider) ID() string
- func (p *Provider) IsHealthy() bool
- func (p *Provider) Models(ctx context.Context) ([]providers.ModelInfo, error)
- func (p *Provider) TestAccount(ctx context.Context, accountID string) error
- func (p *Provider) TestConnection(ctx context.Context) error
- func (p *Provider) Type() string
- type TokenExchangeResponse
Constants ¶
View Source
const ( DefaultCodexClientID = "app_EMoamEEZ73f0CkXaXp7hrann" CodexTokenURL = "https://auth.openai.com/oauth/token" CodexUserAgent = "codex-cli/0.149.0 (Linux; x64)" CodexOriginator = "codex_cli_rs" DefaultCodexBackendURL = "https://chatgpt.com/backend-api/codex/responses" )
View Source
const ( CodexDeviceUserCodeURL = "https://auth.openai.com/api/accounts/deviceauth/usercode" CodexDeviceTokenURL = "https://auth.openai.com/api/accounts/deviceauth/token" CodexDeviceVerifyURI = "https://auth.openai.com/codex/device" CodexDeviceCallbackURI = "https://auth.openai.com/deviceauth/callback" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct {
ID string
Pool string
RefreshToken string
AccessToken string
AccountID string
ExpiresAt time.Time
// contains filtered or unexported fields
}
func ReadCodexCLIAuth ¶
ReadCodexCLIAuth parses ~/.codex/auth.json
type DeviceCodeResponse ¶ added in v0.7.0
type DeviceCodeResponse struct {
DeviceAuthID string `json:"device_auth_id"`
UserCode string `json:"user_code"`
VerificationURI string `json:"verification_uri"`
Interval int `json:"interval"`
ExpiresIn int `json:"expires_in"`
}
func StartDeviceAuth ¶ added in v0.7.0
func StartDeviceAuth(ctx context.Context) (*DeviceCodeResponse, error)
StartDeviceAuth initiates the OpenAI Codex device flow
type DeviceTokenPollResponse ¶ added in v0.7.0
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
func NewProvider ¶
func (*Provider) ChatCompletion ¶
func (p *Provider) ChatCompletion(ctx context.Context, req *providers.ChatRequest) (io.ReadCloser, bool, int, error)
func (*Provider) Embeddings ¶
func (p *Provider) Embeddings(ctx context.Context, req *providers.EmbeddingRequest) (*providers.EmbeddingResponse, error)
func (*Provider) TestAccount ¶
type TokenExchangeResponse ¶ added in v0.7.0
type TokenExchangeResponse struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
ExpiresIn int `json:"expires_in"`
}
func PollAndExchangeDeviceToken ¶ added in v0.7.0
func PollAndExchangeDeviceToken(ctx context.Context, deviceAuthID, userCode string) (*TokenExchangeResponse, error)
PollAndExchangeDeviceToken polls the device auth endpoint and exchanges for tokens
Click to show internal directories.
Click to hide internal directories.