Codex CLI through LiteLLM Gateway on Bedrock Mantle
Route Codex CLI through a LiteLLM gateway into Amazon Bedrock Mantle to reach OpenAI models with gateway controls, model aliases and sane operating defaults.
This article is published in English.
Sources: Using OpenAI Codex CLI with LiteLLM AI Gateway and Amazon Bedrock Mantle
This walkthrough rebuilds the path from raw materials to a working system for: Using OpenAI Codex CLI with LiteLLM AI Gateway and Amazon Bedrock Mantle. The focus is operable steps, explicit checks, and code that you can drop into a repo without guessing intent. For Overview, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.
AWS Support for OpenAI
For AWS Support for OpenAI, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline. Pin dependency versions and record the image digest that ran the demo. Reproducibility beats tribal knowledge.
Accessing Other OpenAI Models
For Accessing Other OpenAI Models, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion. Pin dependency versions and record the image digest that ran the demo. Reproducibility beats tribal knowledge.
Install Codex CLI
For Install Codex CLI, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments. Pin dependency versions and record the image digest that ran the demo. Reproducibility beats tribal knowledge. For Install Codex CLI, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.
curl -fsSL https://chatgpt.com/codex/install.sh | sh
codex --version # currently codex-cli 0.142.5
Confirm LiteLLM Is Running
For Confirm LiteLLM Is Running, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline. Add a smoke test that exercises the critical path in CI with fixtures, not live paid APIs, whenever budgets allow.
export LITELLM_DEMO_CLIENT_KEY="sk-your-litellm-virtual-key"
curl -fsS "http://localhost:4000/models" \
-H "Authorization: Bearer $LITELLM_DEMO_CLIENT_KEY" \
| jq '[.data[]
| select(.id | contains("openai"))
| {id, max_input_tokens, max_output_tokens}]'
Smaller Context Windows
For Smaller Context Windows, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion. Add a smoke test that exercises the critical path in CI with fixtures, not live paid APIs, whenever budgets allow.
Using Bedrock Mantle vs. LiteLLM
For Using Bedrock Mantle vs. LiteLLM, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments. Add a smoke test that exercises the critical path in CI with fixtures, not live paid APIs, whenever budgets allow. For Using Bedrock Mantle vs. LiteLLM, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.
model_provider = "amazon-bedrock"
model = "openai.gpt-5.5"
export AWS_BEARER_TOKEN_BEDROCK="<your-bedrock-api-key>"
export AWS_REGION="us-east-2"
Create a Codex LiteLLM Profile
For Create a Codex LiteLLM Profile, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline. Write a short runbook: how to rotate keys, how to drain the queue, how to roll back the last ingest.
CODEX_HOME="${CODEX_HOME:-$HOME/.codex}"
mkdir -p "$CODEX_HOME"
cat > "$CODEX_HOME/litellm.config.toml" <<EOF
model = "bedrock-mantle-openai-gpt-5-4"
model_provider = "litellm"
model_catalog_json = "$CODEX_HOME/model-catalogs/litellm.json"
[model_providers.litellm]
name = "LiteLLM"
base_url = "http://localhost:4000"
env_key = "LITELLM_DEMO_CLIENT_KEY"
wire_api = "responses"
EOF
wire_api = "responses"
Add Model Metadata for the LiteLLM Aliases
For Add Model Metadata for the LiteLLM Aliases, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion. Write a short runbook: how to rotate keys, how to drain the queue, how to roll back the last ingest.
CODEX_HOME="${CODEX_HOME:-$HOME/.codex}"
mkdir -p "$CODEX_HOME/model-catalogs"
jq '{
models: [
(.models[]
| select(.slug == "gpt-5.4")
| .slug = "bedrock-mantle-openai-gpt-5-4"
| .display_name = "LiteLLM Bedrock GPT-5.4"
| .description = "LiteLLM alias for GPT-5.4 through Bedrock Mantle."
| .upgrade = null
| .availability_nux = null
| .max_context_window = .context_window),
(.models[]
| select(.slug == "gpt-5.5")
| .slug = "bedrock-mantle-openai-gpt-5-5"
| .display_name = "LiteLLM Bedrock GPT-5.5"
| .description = "LiteLLM alias for GPT-5.5 through Bedrock Mantle."
| .upgrade = null
| .availability_nux = null)
]
}' "$CODEX_HOME/models_cache.json" > "$CODEX_HOME/model-catalogs/litellm.json"
Optional: But you want GPT-5.4 mini
For Optional: But you want GPT-5.4 mini, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments. Write a short runbook: how to rotate keys, how to drain the queue, how to roll back the last ingest. For Optional: But you want GPT-5.4 mini, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.
CODEX_HOME="${CODEX_HOME:-$HOME/.codex}"
mkdir -p "$CODEX_HOME/model-catalogs"
jq '{
models: [
(.models[]
| select(.slug == "gpt-5.4")
| .slug = "bedrock-mantle-openai-gpt-5-4"
| .display_name = "LiteLLM Bedrock GPT-5.4"
| .description = "LiteLLM alias for GPT-5.4 through Bedrock Mantle."
| .upgrade = null
| .availability_nux = null
| .max_context_window = .context_window),
(.models[]
| select(.slug == "gpt-5.5")
| .slug = "bedrock-mantle-openai-gpt-5-5"
| .display_name = "LiteLLM Bedrock GPT-5.5"
| .description = "LiteLLM alias for GPT-5.5 through Bedrock Mantle."
| .upgrade = null
| .availability_nux = null
| .max_context_window = .context_window),
(.models[]
| select(.slug == "gpt-5.4-mini")
| .slug = "openai-gpt-5-4-mini"
| .display_name = "LiteLLM OpenAI GPT-5.4 Mini"
| .description = "LiteLLM alias for GPT-5.4 mini through OpenAI."
| .upgrade = null
| .availability_nux = null
| .max_context_window = .context_window)
]
}' "$CODEX_HOME/models_cache.json" > "$CODEX_HOME/model-catalogs/litellm.json"
Start Codex Through LiteLLM
For Start Codex Through LiteLLM, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Prefer small, testable units over sprawling scripts. When a step fails, the failure should point at a single responsibility rather than a tangled pipeline. Pin dependency versions and record the image digest that ran the demo. Reproducibility beats tribal knowledge.
codex --profile litellm
codex --profile litellm -m bedrock-mantle-openai-gpt-5-5
Why This Works
For Why This Works, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion. Pin dependency versions and record the image digest that ran the demo. Reproducibility beats tribal knowledge.
codex --profile litellm
References
For References, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments. Pin dependency versions and record the image digest that ran the demo. Reproducibility beats tribal knowledge. For References, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state. Document the happy path and the recovery path together. Retries, human gates, and dead-letter handling are part of the product, not later polish.
Operational checklist
For Operational checklist, define the inputs, the owner of the step, and the exit criteria before changing code. Operators should be able to re-run the step from a known checkpoint without guessing hidden state.
Keep configuration outside application code. Environment files, secret stores, and feature flags belong in one place operators can audit without reading the whole graph.
Add a smoke test that exercises the critical path in CI with fixtures, not live paid APIs, whenever budgets allow.
Record timings and token or query cost next to functional results. Cost visibility early prevents surprise bills when the path moves from demo to shared environments.
Pin dependency versions and record the image digest that ran the demo. Reproducibility beats tribal knowledge.
Treat this stage as a contract between inputs and validated outputs. Name the artifacts, define success checks, and refuse silent partial completion.
Before promoting the stack, freeze versions, capture a golden transcript for the critical path, and confirm rollback steps. Shared environments need rate limits, tenancy checks, and a clear owner for secret rotation. Prefer boring reliability over clever one-off demos.