OpenAI Codex — sx_provider_codex.c

Provedor Codex

Análise profunda do provedor OpenAI Codex — modelos, autenticação, recursos e configuração.

Visão geral

O provedor Codex conecta o scorpiox code ao backend OpenAI Codex via autenticação OAuth Bearer. Ele se comunica com a API backend do ChatGPT e suporta streaming, pensamento estendido, uso de ferramentas, chamadas de função, visão e atualização automática de tokens.

# API endpoint
POST https://chatgpt.com/backend-api/codex/responses

# Auth header
Authorization: Bearer <oauth_token>

# Source file
impl: scorpiox/libsxnet/sx_provider_codex.c

Modelos suportados

gpt-5.3-codex
Flagship
Latest Codex flagship model. Maximum reasoning depth, extended context, best for complex multi-file refactors and architecture work.
gpt-5.3-codex-spark
Spark
Lightweight 5.3 variant optimized for speed. Best for quick edits, completions, and interactive coding sessions.
gpt-5.2-codex
Standard
Previous-generation flagship. Proven reliability for production workloads and general-purpose coding tasks.
gpt-5.2
Standard
General GPT-5.2 model. Broader capabilities beyond code — documentation, analysis, and reasoning.
gpt-5.1-codex
Standard
Stable 5.1 generation. Well-tested for day-to-day development tasks with consistent output quality.
gpt-5.1-codex-mini
Mini
Compact 5.1 variant. Lower latency and cost, ideal for simple tasks like formatting, renaming, and boilerplate.
gpt-5.1-codex-max
Max
Maximum-capacity 5.1 model. Extended thinking budget and larger context window for deep analysis.

Recursos

Streaming
Real-time token streaming via SSE for responsive TUI output
🧠
Extended Thinking
Chain-of-thought reasoning with configurable thinking budget
🔧
Tool Use
Full tool execution — file ops, bash, search, docs, and more
📞
Function Calling
Native OpenAI function calling for structured tool invocations
👁️
Vision
Image input support for screenshots, diagrams, and UI reviews
🔄
Token Refresh
Automatic OAuth token rotation via scorpiox-codex-fetchtoken

Autenticação

O Codex usa autenticação OAuth Bearer via header Authorization. Os tokens são gerenciados pelo scorpiox-codex-fetchtoken e podem ser obtidos de três fontes:

Fontes de tokens

Local CODEX_TOKEN_SOURCE=local
Reads the OAuth token from a local file managed by scorpiox-codex-fetchtoken. Default mode — no network calls needed for token acquisition. The token file is stored alongside your scorpiox configuration.
Remote CODEX_TOKEN_SOURCE=remote
Fetches the token from a remote HTTP endpoint configured via CODEX_REMOTE_URL. Default URL: https://token.scorpiox.net/codex. Useful for centralized token management across teams.
SSH CODEX_TOKEN_SOURCE=ssh
Retrieves the token over SSH from a remote machine. Configure via CODEX_SSH_HOST, CODEX_SSH_USER, CODEX_SSH_PASS, and CODEX_SSH_PORT. Ideal for air-gapped or private infrastructure environments.

Configuração

Todas as configurações do Codex são armazenadas em scorpiox-env.txt na raiz do projeto. Execute scorpiox-config para configurar interativamente.

KeyDescriptionDefault
PROVIDERSet to codex to use this providerscorpiox
MODELModel name or alias (e.g. gpt-5.3-codex)sonnet
TOOLSEnable/disable all tool execution1
CODEX_TOKEN_SOURCEToken acquisition method: local, remote, sshlocal
CODEX_REMOTE_URLRemote HTTP endpoint for token fetchinghttps://token.scorpiox.net/codex
CODEX_SSH_HOSTSSH hostname for remote token retrieval
CODEX_SSH_USERSSH username
CODEX_SSH_PASSSSH password
CODEX_SSH_PORTSSH port number

Início rápido

1. Switch to Codex provider

# In scorpiox-env.txt
PROVIDER=codex
MODEL=gpt-5.3-codex
CODEX_TOKEN_SOURCE=local

# Or use scorpiox-config interactively
$ scorpiox-config

2. Fetch your token

# Local token (default)
$ scorpiox-codex-fetchtoken

# Remote token from team server
$ CODEX_TOKEN_SOURCE=remote scorpiox-codex-fetchtoken

# SSH token from bastion host
$ CODEX_TOKEN_SOURCE=ssh CODEX_SSH_HOST=bastion.internal scorpiox-codex-fetchtoken

3. Start coding

# Launch scorpiox code with Codex backend
$ sx

# Or specify model inline
$ sx --provider codex --model gpt-5.3-codex-spark

Comparação de provedores

FeatureCodexClaude CodeAnthropicGeminiOpenAIRouter
Streaming
Thinking
Tool Use
Function Calling
Vision
Token Refresh
Context Caching
Auth MethodOAuth BearerOAuth Bearerx-api-keyAPI KeyAPI KeyNone

Implementação fonte

The Codex provider is implemented as a single-file C module following the scorpiox provider interface pattern:

// Provider source
scorpiox/libsxnet/sx_provider_codex.c

// Token fetcher binary
scorpiox/scorpiox-codex-fetchtoken.c

// Provider interface (shared by all providers)
scorpiox/libsxnet/sx_provider.h

// Config integration
scorpiox/libsxutil/sx_config.c → CODEX_TOKEN_SOURCE, MODEL

All providers compile as part of libsxnet and are statically linked into the sx binary. Zero runtime dependencies — the Codex provider uses raw socket HTTP built into scorpiox's networking layer.