Non-interactive execution, CI and SDKs
Use codex exec, GitHub Actions, app-server, Codex SDK and Agents SDK with scoped credentials.
Three common automation paths are:
| Path | Suitable work | Entry point |
|---|---|---|
| Script / CI | Checks, diff review, patch generation | codex exec |
| GitHub Actions | PR review, CI fixes, release checks | openai/codex-action@v1 |
| Product integration | Events, threads, approvals and orchestration | Codex SDK or app-server |
#codex exec
Minimal invocation:
codex exec "review the current diff and list only P0/P1 risks"Explicit permissions:
codex exec \
--sandbox read-only \
--ask-for-approval never \
"summarize this repo and identify risky areas"Continue a session:
codex exec "find the likely cause of this failing test"
codex exec resume --last "apply the smallest fix and rerun the test"For repeatable tasks, version a prompt file instead of maintaining a long string inside CI YAML.
#API-key automation
CODEX_API_KEY applies to codex exec and can be scoped to a single command:
CODEX_API_KEY="$OPENAI_API_KEY" \
codex exec --json "triage open bug reports"Do not expose a key to unrelated later steps. Installing dependencies before introducing the model credential reduces its exposure to installation scripts.
#Passion8 CI
Use the standard Codex files or a dedicated temporary configuration directory:
export CODEX_HOME="$PWD/.codex-ci"
mkdir -p "$CODEX_HOME"
cat > "$CODEX_HOME/auth.json" << 'EOF'
{
"OPENAI_API_KEY": "YOUR_PASSION8_API_KEY"
}
EOF
cat > "$CODEX_HOME/config.toml" << 'EOF'
model_provider = "Passion8"
cli_auth_credentials_store = "file"
forced_login_method = "api"
model = "gpt-6-sol"
approval_policy = "never"
sandbox_mode = "workspace-write"
[model_providers.Passion8]
name = "Passion8"
wire_api = "responses"
requires_openai_auth = true
base_url = "https://passion8.cc/v1"
EOF
codex exec "run the documented checks and summarize failures"Inject the actual key with your CI secret mechanism; do not commit a populated example or upload .codex-ci/auth.json as an artifact.
#GitHub Action
The official Action installs Codex, starts its Responses proxy and runs the configured task. It can reduce custom installation and credential wiring.
name: Codex review
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
codex:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
persist-credentials: false
- uses: openai/codex-action@v1
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
prompt-file: .github/codex/prompts/review.md
sandbox: read-onlyThis is the official-provider example. Do not assume it inherits the local Passion8 configuration.
Practical boundaries:
- Limit triggers so untrusted fork PRs do not receive secrets.
- Avoid persisted checkout credentials unless a later step needs them.
- Let the model job produce a diff or report.
- Put PR-writing in a separate job without the model key.
- Treat issue text, PR bodies and commit messages as untrusted task data.
#Automatically propose CI fixes
A useful pattern is:
- Trigger a separate workflow after the primary CI fails.
- Check out the failing commit.
- Install dependencies before introducing the model key.
- Run Codex to produce a patch.
- Upload the patch artifact.
- Use another job to apply the patch and open a PR.
This separates model credentials from the job that has repository write access.
#App Server
app-server supports deeper product integration with JSON-RPC-style messages for threads, turns, streaming events, approvals and history.
codex app-server
codex app-server --listen ws://127.0.0.1:4500
codex app-server --listen unix://Use localhost or an SSH tunnel for WebSocket transport. Do not expose an unauthenticated non-loopback listener.
#Codex SDK
The SDK is useful in backend services or internal platforms that need:
- Long conversations.
- Streaming events.
- Structured output.
- Approval and tool-result handling.
- Agent orchestration.
For a single CI review, exec or the Action is simpler. Choose the SDK when product integration or orchestration needs justify it.
#Agents SDK with Codex MCP
Expose Codex as an MCP server:
codex mcp-serverTypical uses:
- A coordinating agent delegates code implementation to Codex.
- A multi-agent pipeline treats Codex as a reviewable implementation worker.
- Agents SDK coordinates handoffs, traces and guardrails.
Give each task a clear scope and an independent directory or worktree.
#Official references
Support
Need help?
For setup, billing, or model issues, email us. Check the status page for uptime.
WeChat / QQ support is available at the bottom right.

