codex

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package codex adapts the OpenAI Codex Responses API (ChatGPT backend) to cogito.LLM.

The Codex backend lives at https://chatgpt.com/backend-api/codex/responses and speaks the same Responses wire format as the standard OpenAI Responses API, but with Codex-specific constraints:

  • No sampling parameters (temperature, top_p) or output caps
  • store is always false; stream is always true (SSE)
  • Codex identity headers (originator, version, chatgpt-account-id from JWT)
  • include: ["reasoning.encrypted_content"]

Response decoding reuses the openairesponses package — the SSE stream's terminal response.completed event carries the full response object in the same JSON shape as a non-streaming Responses API response.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoResponse = errors.New("codex: completed without an assistant message")

ErrNoResponse is returned when the API completes without an assistant message.

Functions

This section is empty.

Types

type Config

type Config struct {
	Model           string
	Token           string // OAuth access token (JWT)
	ReasoningEffort string // "", "none", "minimal", "low", "medium", "high", "xhigh", "max"
	ServiceTier     string // "", "auto", "default", "flex", "scale", "priority"
	ResponsesLite   bool
}

Config holds the connection + auth parameters for the Codex adapter.

type LLM

type LLM struct {
	// contains filtered or unexported fields
}

LLM implements cogito.LLM against the Codex Responses API.

func New

func New(config Config) *LLM

New returns a Codex adapter.

func (*LLM) Ask

func (l *LLM) Ask(ctx context.Context, fragment cogito.Fragment) (cogito.Fragment, error)

Ask delegates to CreateChatCompletion.

func (*LLM) CreateChatCompletion

func (l *LLM) CreateChatCompletion(ctx context.Context, request openai.ChatCompletionRequest) (cogito.LLMReply, cogito.LLMUsage, error)

CreateChatCompletion translates an OpenAI Chat Completion request to the Codex Responses API, calls it via SSE, and translates the response back.

func (*LLM) ListModels added in v0.9.1

func (l *LLM) ListModels(ctx context.Context) ([]string, error)

ListModels returns the Codex models visible to this ChatGPT account. Entries the backend marks hidden are left out, as the Codex CLI does.

Jump to

Keyboard shortcuts

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