Community n8n AI Chat Model node: OpenAI codex.
Follow n8n community node installation docs:
- Node name:
OpenAI codex - Type: AI Language Model root node (
ai_languageModel) - Device-code login flow compatible with Codex-style auth endpoints
- Auth state persisted on disk and reused across runs
- Automatic token refresh (proactive refresh before expiry)
- Dynamic model catalog from backend
/models(cached on disk) - Reasoning-effort options loaded from selected model capability
- Tool-calling support for n8n AI Agent (exact tool-name preservation)
- Explicit context strategy switch:
Memory OnlyorBackend Chain (previous_response_id) - Strict model-to-reasoning validation (invalid model/effort combinations are rejected)
- Runtime model-substitution guard (throws if backend returns a different model slug)
- Add the
OpenAI codexnode. - Click Test step.
- If login is required, the node output/error contains:
- verification URL
- user code
- Complete login in the browser, then click Test step again.
- Default auth state path:
$N8N_USER_FOLDER/openai-codex-state - Fallback path:
~/.n8n/openai-codex-state - Override path:
N8N_OPENAI_CODEX_STATE_DIR=/absolute/path
Memory Only (n8n Memory):previous_response_idis disabled.- Use n8n Memory nodes (Simple/Redis/Postgres/Mongo/etc.) as context source.
Backend Chain (previous_response_id):Session Keyis required.- The node stores and reuses
previous_response_idperSession Key. - Use a stable key per conversation/user (for example
={{ $json.userId }}).
Use one strategy at a time to avoid redundant context.
- Base URL:
https://chatgpt.com/backend-api/codex - Originator header:
codex_cli_rs
- Asking the model "what model are you?" is not a reliable identity check.
- Use backend metadata (
response.model) instead. - This node validates backend-returned model slug against the requested model and fails fast on mismatch.
pnpm install
pnpm lint
pnpm build