openai

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 14 Imported by: 0

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 New

func New(apiKey string) *OpenAI

New creates an OpenAI provider using an API key (api.openai.com).

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

func NewWithBaseURL(apiKey, baseURL string) *OpenAI

NewWithBaseURL creates an OpenAI provider with a custom base URL (for testing).

func (*OpenAI) Stream

func (o *OpenAI) Stream(ctx context.Context, req core.Request) (<-chan core.AssistantEvent, error)

Stream sends a request and returns a channel of normalized AssistantEvents.

func (*OpenAI) SupportsDocuments

func (o *OpenAI) SupportsDocuments() bool

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.

Jump to

Keyboard shortcuts

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