This private OpenCode build adds a native codex provider for Codex-compatible
Responses API gateways.
- Adds
codexas a first-class provider id. - Supports model selection like
codex/gpt-5.4. - Sends Codex-style requests to
POST <baseURL>/responses. - Sends Codex compatibility headers such as
x-client-request-id,x-codex-window-id, and installation metadata. - Maps Codex tool calls back into OpenCode's normal tool execution flow.
- Sends OpenCode, plugin, and MCP function tools to Codex-compatible gateways as portable JSON-schema function tools.
- Keeps Claude/OmO/Superpowers skills discoverable from
~/.claude/skillsand~/.agents/skills. - Lets you configure a private Codex-compatible API base without a MITM proxy.
The provider id must be codex. A custom provider id such as other or
internalcodex will not use the native Codex transport.
Create or update your OpenCode config at ~/.config/opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"codex": {
"name": "Codex",
"env": ["CODEX_API_KEY"],
"npm": "@opencode-ai/codex",
"options": {
"baseURL": "https://your-codex-gateway.example/v1"
}
}
}
}Rules:
- Set
baseURLto the parent URL that has a/responsesendpoint. - Do not include
/responsesinbaseURL; the provider appends it. - Use models as
codex/<model>, for examplecodex/gpt-5.4. auth loginstores credentials in~/.local/share/opencode/auth.json, not inopencode.json.
opencode-codex should expose the same user skill trees as normal OpenCode:
~/.claude/skills/**/SKILL.md~/.agents/skills/**/SKILL.md- project
.claude/skills/**/SKILL.md - project
.agents/skills/**/SKILL.md - configured
skills.paths - configured
skills.urls
Nested skills such as ~/.claude/skills/Utilities/Documents/SKILL.md are
supported. Setting OPENCODE_DISABLE_CLAUDE_CODE_SKILLS=1 disables only the
Claude Code compatibility skill behavior; it does not hide OmO/Superpowers skill
trees. Set OPENCODE_DISABLE_EXTERNAL_SKILLS=1 only when you intentionally want
to disable all external .claude and .agents skill discovery.
Codex provider tool behavior:
apply_patchis declared as a Codex custom grammar tool.- OpenCode
bashis declared as a portable JSON-schema function tool instead of native Codexlocal_shell, because this private gateway rejects nativelocal_shell. - OpenCode built-in tools, plugin tools, and MCP tools are declared as generic Codex function tools when they have JSON-schema input.
This is first-class OpenCode provider behavior for this private gateway, but it is still Codex-compatible gateway mode rather than exact upstream Codex CLI wire parity for shell execution.
Use environment auth:
export CODEX_API_KEY="your-api-key"Or use OpenCode auth storage:
opencode-codex auth login
opencode-codex auth listSelect Codex when prompted.
Requirements:
- macOS arm64 for the binary path used by these scripts.
- Bun 1.3 or newer.
- This repository checked out with the Codex provider patch applied.
Build from the repository root:
./build.shThis creates and verifies:
packages/opencode/dist/opencode-darwin-arm64/bin/opencodeInstall as opencode-codex:
./install.shInstall with another command name:
./install.sh --name opencode-privateReplace the normal opencode command with this private build:
./install.sh --replaceIf ~/.local/bin is not in PATH:
export PATH="$HOME/.local/bin:$PATH"Use the private build with a Codex model:
opencode-codex -m codex/gpt-5.4For a non-interactive smoke test in a temporary directory:
tmp="$(mktemp -d /tmp/opencode-codex-XXXXXX)"
cd "$tmp"
cat > opencode.json <<'JSON'
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"apply_patch": "allow",
"edit": "allow",
"write": "allow",
"bash": "allow"
}
}
JSON
opencode-codex run --pure --model codex/gpt-5.4 --dangerously-skip-permissions \
'write a hello world python script to hello.py'
test -s hello.py
cat hello.pyThe test passes if hello.py exists and is not empty.
If codex/gpt-5.4 says no auth is available:
- Confirm the model starts with
codex/. - Confirm
CODEX_API_KEYis exported oropencode-codex auth listshows aCodexcredential. - Confirm you are running the private binary with
opencode-codex --version.
If requests hit the wrong endpoint:
- Confirm
provider.codex.options.baseURLis set in~/.config/opencode/opencode.json. - Confirm the configured URL does not already end in
/responses.
If the model replies with code text but does not write files:
- Check local permission rules. A global rule denying
apply_patchcan prevent file creation. - Retry with
--pureand a localopencode.jsonthat allowsapply_patch. - Use
--dangerously-skip-permissionsonly in a disposable test directory.
If a skill such as Documents is missing:
-
Confirm the skill file has frontmatter with a
namematching the name you ask theskilltool to load. Skill names are case-sensitive. -
Confirm the skill lives under one of the scanned trees, for example
~/.claude/skills/Utilities/Documents/SKILL.md. -
Confirm
OPENCODE_DISABLE_EXTERNAL_SKILLSis not set. -
Run the same
opencode-codexbinary you installed with./install.sh; stale binaries may not include the private skill-discovery behavior. -
Add an explicit config path if needed:
{ "$schema": "https://opencode.ai/config.json", "skills": { "paths": ["~/.claude/skills", "~/.agents/skills"] } }
If the binary is missing:
- Run
./build.shagain from the repository root. - Confirm you are on macOS arm64 when using this guide's default binary path.
- Check that
packages/opencode/dist/opencode-darwin-arm64/bin/opencodeis executable.