codex

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseAPIError

func ParseAPIError(err error) (statusCode int, body string, ok bool)

ParseAPIError 解包 resty 的 APIError,便于上层按状态码分类处理

Types

type Client

type Client struct {

	// OnQuota 响应头配额回调,Responses 每次收到响应后自动解析并调用
	OnQuota func(ctx context.Context, credentialID string, q *codexutils.Quota)
	// contains filtered or unexported fields
}

func NewClient

func NewClient() *Client

func (*Client) APIType

func (c *Client) APIType() []utils.APIType

func (*Client) Chat

func (c *Client) Chat(req *api.Request) (*http.Response, error)

Chat 向上游 Codex API 发送请求,返回原始 *http.Response(调用方负责关闭 Body) headers 应已包含认证头(Authorization, Chatgpt-Account-Id 等),由调用方负责组合 OnBeforeRequest 最终强制 User-Agent 等默认头

func (*Client) FetchQuota

func (c *Client) FetchQuota(ctx context.Context, credentialID, accessToken string) (*codexutils.Quota, error)

func (*Client) HandlerType

func (c *Client) HandlerType() utils.HandlerType

func (*Client) RefreshAccessToken

func (c *Client) RefreshAccessToken(ctx context.Context, refreshToken string) (*codexutils.CodexTokenData, bool, error)

func (*Client) ReplaceModel

func (c *Client) ReplaceModel(body []byte, model string) []byte

func (*Client) SetSettingsProvider

func (c *Client) SetSettingsProvider(provider settings.Provider)

type RTResponse

type RTResponse struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	IDToken      string `json:"id_token"`
	ExpiresIn    int    `json:"expires_in"`
}

Directories

Path Synopsis
convert

Jump to

Keyboard shortcuts

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