Documentation
¶
Overview ¶
Package openai implements core.Provider for the OpenAI Responses API. Supports GPT and Codex models with streaming, tool use, and reasoning effort. Works with both API keys (api.openai.com) and OAuth (chatgpt.com/backend-api).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OpenAI ¶
type OpenAI struct {
// contains filtered or unexported fields
}
OpenAI implements core.Provider for the OpenAI Responses API.
func NewOAuth ¶
func NewOAuth(accessToken, accountID string, refresh func(rejectedToken string) (string, error)) *OpenAI
NewOAuth creates an OpenAI provider using ChatGPT subscription OAuth. Uses chatgpt.com/backend-api with the /codex/responses endpoint.
func NewWithBaseURL ¶
NewWithBaseURL creates an OpenAI provider with a custom base URL (for testing).
func (*OpenAI) SupportsDocuments ¶
SupportsDocuments returns true only for the API-key path (/v1/responses): the codex OAuth path (/codex/responses) is unverified for input_file.
func (*OpenAI) Transcribe ¶
func (o *OpenAI) Transcribe(ctx context.Context, audio io.Reader, filename string, opts core.TranscribeOptions) (string, error)
Transcribe sends audio to the OpenAI transcription API and returns the text. filename should include the extension (e.g. "audio.webm") so the API can detect the format. Supported formats: mp3, mp4, mpeg, mpga, m4a, wav, webm, ogg.
opts.Model selects the transcription model; empty falls back to the package default. Note that response_format stays "json": the newer models reject "verbose_json", and we only ever read the text field anyway.