Documentation
¶
Overview ¶
Package codex is a provider speaking the Responses API.
Index ¶
- Constants
- Variables
- func CredentialsPath() string
- func Login() error
- type Client
- func (self *Client) AddToolResults(results []agent.ToolResult)
- func (self *Client) AddUserMessage(prompt string)
- func (self *Client) Configure(instructions string, tools []tool.Definition)
- func (self *Client) Dump() []json.RawMessage
- func (self *Client) Load(items []json.RawMessage)
- func (self *Client) Send(ctx context.Context, yield agent.Yield) (agent.Reply, error)
- type Credentials
- type Token
- type TokenSource
Constants ¶
const ( Endpoint = "https://chatgpt.com/backend-api/codex/responses" Model = "gpt-5.6-sol" Effort = "high" Summary = "auto" // defined as the "most detailed summarizer available for a model" Originator = "io" // who we? )
https://platform.openai.com/docs/api-reference/responses/create https://platform.openai.com/docs/guides/reasoning
Variables ¶
var ErrIncomplete = errors.New("the response was cut short")
ErrIncomplete is a response the endpoint cut short, usually against a limit.
var ErrTruncated = sse.ErrTruncated
ErrTruncated is a stream that stopped without ever saying it was finished, which means the wire went quiet mid-turn rather than the model reaching an end.
var TokenURL string
TokenURL is the address credentials are traded at, and is the real one when left empty.
Functions ¶
func CredentialsPath ¶
func CredentialsPath() string
CredentialsPath is where Login writes and Auth reads.
Types ¶
type Client ¶
type Client struct {
URL string // the endpoint address
Model string // the model to ask
Effort string // how hard the model should reason
// contains filtered or unexported fields
}
Client speaks the Responses API: one request per turn, answered as a stream of events.
https://platform.openai.com/docs/api-reference/responses/create https://platform.openai.com/docs/api-reference/responses-streaming https://platform.openai.com/docs/guides/conversation-state
func New ¶
func New(tokens TokenSource) *Client
New builds a client that authorises every request with the given source.
func (*Client) AddToolResults ¶
func (self *Client) AddToolResults(results []agent.ToolResult)
AddToolResults appends this turn's tool call results to the conversation.
func (*Client) AddUserMessage ¶
AddUserMessage appends a prompt to the conversation.
func (*Client) Configure ¶
func (self *Client) Configure(instructions string, tools []tool.Definition)
Configure takes what every request in the session carries.
func (*Client) Dump ¶
func (self *Client) Dump() []json.RawMessage
Dump hands over the conversation so far, one item per entry, in the order the endpoint expects them back. New state is appended and earlier items are never replaced.
func (*Client) Load ¶
func (self *Client) Load(items []json.RawMessage)
Load takes a conversation back, replacing whatever this client held.
type Credentials ¶
type Credentials struct {
Access string `json:"access"` // the access token
Refresh string `json:"refresh"` // the refresh token
ExpiresAt int64 `json:"expires_at"` // when access expires
AccountID string `json:"account_id"` // the ChatGPT account
}
Credentials are what a ChatGPT subscription was authorised as.
type TokenSource ¶
TokenSource hands over a token to make a request with.
func Static ¶
func Static(access string, accountID string) TokenSource
Static is a token that is already held, and never changes.
func StoredCredentials ¶
func StoredCredentials() TokenSource
StoredCredentials reads and refreshes credentials written by Login.
func StoredCredentialsAt ¶
func StoredCredentialsAt(path string) TokenSource
StoredCredentialsAt reads credentials from path.