cd /news/ai-agents/deploy-codex-cli-with-bedrock-throug… · home › topics › ai-agents › article
[ARTICLE · art-172275] src=agentgateway.dev ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

Deploy Codex CLI with Bedrock Through agentgateway

A walkthrough published on GitHub by sebbycorp shows how to run OpenAI's Codex CLI against an OpenAI model on Amazon Bedrock with no API key on the laptop, using open source agentgateway v1.7.0 in a local kind cluster. The gateway accepts Codex's OpenAI Responses API calls on localhost, rewrites the model name gpt-oss-120b to Bedrock's openai.gpt-oss-120b-1:0, returns 404 for any other model name, and logs each request's token count and cost to a Postgres database for the agentgateway UI. The setup installs Gateway API v1.6.3 CRDs plus agentgateway-crds and agentgateway Helm charts at v1.7.0, and also exposes an MCP endpoint at /mcp backed by search.solo.io/mcp.

recommendation

Route Codex CLI through agentgateway v1.7.0 to reach Bedrock's openai.gpt-oss-120b-1:0 without a local API key, and attach a Postgres request-log database so the UI's Logs and Analytics pages report token counts and cost.

more in playbook: Inference and self-hosting
read8 min views2 publishedNov 18, 2026

Codex CLI wants an OpenAI-shaped endpoint and an API key. I wanted neither on my laptop. The goal for this build: Codex talks to a gateway on localhost with no key at all, the gateway sends the request to an OpenAI model running on Amazon Bedrock, and every call shows up in a log with its token count and cost.

All of it runs on open source agentgateway v1.7.0 in a local kind cluster. The manifests and the full step list are in sebbycorp/agentgateway-oss-k8s.

What you end up with:

gpt-oss-120b. The gateway rewrites that to Bedrock’s openai.gpt-oss-120b-1:0. Any other model name gets a 404./mcp.

flowchart LR
C[Codex CLI<br/>no API key] -->|/v1/responses| LB[cloud-provider-kind<br/>localhost port]
C -->|/mcp| LB
LB --> P[agentgateway proxy]
P -->|Converse + Bedrock API key| B[Amazon Bedrock<br/>openai.gpt-oss-120b-1:0]
P -->|streamable HTTP| M[search.solo.io/mcp]
P -->|request log| DB[(Postgres)]
DB --> UI[agentgateway UI<br/>Logs / Analytics]

Codex speaks the OpenAI Responses API. Bedrock does not. agentgateway translates between the two, which is the part that makes this work without touching Codex.

kind, kubectl, helm, jq, openssl`` cloud-provider-kind``us-east-2)

export BEDROCK_API_KEY='<your Bedrock API key>'
export CTX=kind-agentgateway-codex

Every command below pins --context $CTX. I had another cluster as my current context when I started, and I did not want a Helm install landing there.

kind create cluster --name agentgateway-codex

In a second terminal, start cloud-provider-kind and leave it running:

cloud-provider-kind --gateway-channel disabled --enable-lb-port-mapping

Two flags, both needed on a Mac:

--gateway-channel disabled``--enable-lb-port-mapping`` sudo required. Without it (and without please run this again with `sudo` . Gateway API CRDs first, then two Helm releases: the agentgateway CRDs and the controller.

kubectl --context $CTX apply --server-side --force-conflicts \
 -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.6.3/standard-install.yaml

helm upgrade -i agentgateway-crds oci://cr.agentgateway.dev/charts/agentgateway-crds \
 --kube-context $CTX --create-namespace --namespace agentgateway-system --version v1.7.0

helm upgrade -i agentgateway oci://cr.agentgateway.dev/charts/agentgateway \
 --kube-context $CTX --namespace agentgateway-system --version v1.7.0 \
 --set controller.image.pullPolicy=Always --wait

Helm only installs the controller. The proxy itself is created later, by the controller, when it sees a Gateway resource. That matters in step 4.

agentgateway ships without a request-log database. Without one, the UI’s Logs and Analytics pages answer request log database is not configured. A SQLite file in the pod works for a quick look, but it is per-pod and gone on restart, so I run Postgres in the cluster. For production, use a managed Postgres instead.

kubectl --context $CTX -n agentgateway-system create secret generic agentgateway-db \
 --from-literal=password="$(openssl rand -hex 24)"
apiVersion: v1
kind: Service
metadata:
 name: agentgateway-db
 namespace: agentgateway-system
spec:
 clusterIP: None
 selector:
 app: agentgateway-db
 ports:
 - name: postgres
 port: 5432
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
 name: agentgateway-db
 namespace: agentgateway-system
spec:
 serviceName: agentgateway-db
 replicas: 1
 selector:
 matchLabels:
 app: agentgateway-db
 template:
 metadata:
 labels:
 app: agentgateway-db
 spec:
 containers:
 - name: postgres
 image: postgres:17
 ports:
 - containerPort: 5432
 name: postgres
 env:
 - name: POSTGRES_DB
 value: agentgateway
 - name: POSTGRES_USER
 value: agentgateway
 - name: POSTGRES_PASSWORD
 valueFrom:
 secretKeyRef:
 name: agentgateway-db
 key: password
 - name: PGDATA
 value: /var/lib/postgresql/data/pgdata
 readinessProbe:
 exec:
 command: ["pg_isready", "-U", "agentgateway", "-d", "agentgateway"]
 periodSeconds: 5
 volumeMounts:
 - name: data
 mountPath: /var/lib/postgresql/data
 volumeClaimTemplates:
 - metadata:
 name: data
 spec:
 accessModes: ["ReadWriteOnce"]
 resources:
 requests:
 storage: 5Gi

The proxy learns about the database through an AgentgatewayParameters resource. There is no typed field for it and no Helm value, so it goes in rawConfig:

apiVersion: agentgateway.dev/v1alpha1
kind: AgentgatewayParameters
metadata:
 name: agentgateway-proxy-params
 namespace: agentgateway-system
spec:
 rawConfig:
 config:
 database:
 url: "postgres://agentgateway:${PG_PASSWORD}@agentgateway-db.agentgateway-system.svc.cluster.local:5432/agentgateway"

${PG_PASSWORD} is a placeholder so the password stays out of git. Substitute it when you apply:

PG_PASSWORD=$(kubectl --context $CTX -n agentgateway-system get secret agentgateway-db \
 -o jsonpath='{.data.password}' | base64 -d)
sed "s/\${PG_PASSWORD}/$PG_PASSWORD/" 04-gateway-parameters.yaml | kubectl --context $CTX apply -f -

One honest caveat: rawConfig has no Secret reference, so the password ends up in plain text inside that resource in the cluster. Restrict who can read the namespace.

apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
 name: agentgateway-proxy
 namespace: agentgateway-system
spec:
 gatewayClassName: agentgateway
 listeners:
 - protocol: HTTP
 port: 80
 name: http
 allowedRoutes:
 namespaces:
 from: All
 kinds:
 - group: gateway.networking.k8s.io
 kind: HTTPRoute
 - group: agentgateway.dev
 kind: AgentgatewayModel
 infrastructure:
 parametersRef:
 group: agentgateway.dev
 kind: AgentgatewayParameters
 name: agentgateway-proxy-params

Two things in here are easy to miss:

kinds must list AgentgatewayModel`` parametersRef must point at something that exists.Programmed=False and no proxy was created. Apply step 3 first. Store the Bedrock key, then publish the model.

kubectl --context $CTX -n agentgateway-system create secret generic bedrock-secret \
 --from-literal=Authorization="$BEDROCK_API_KEY"
apiVersion: agentgateway.dev/v1alpha1
kind: AgentgatewayModel
metadata:
 name: gpt-oss-120b
 namespace: agentgateway-system
spec:
 parentRefs:
 - group: gateway.networking.k8s.io
 kind: Gateway
 name: agentgateway-proxy
 sectionName: http
 provider: Bedrock
 bedrock:
 region: us-east-2
 policies:
 auth:
 secretRef:
 name: bedrock-secret
 transformations:
 - field: model
 expression: '"openai.gpt-oss-120b-1:0"'

How this reads:

metadata.name is the model name clients use.model transformation is what Bedrock receives.policies.auth.secretRef is for a Bedrock API keypolicies.auth.aws.secretRef, which is for IAM access keys, and the model reported accessKey is missing or not a valid string. Find the port cloud-provider-kind published:

export INGRESS_GW_ADDRESS=localhost:$(docker port $(docker ps --filter name=kindccm -q) 80/tcp | head -1 | awk -F: '{print $NF}')

No Authorization header on either call. The gateway adds it.

curl -s "http://$INGRESS_GW_ADDRESS/v1/models" | jq -r '.data[].id'

curl -s "http://$INGRESS_GW_ADDRESS/v1/responses" -H content-type:application/json \
 -d '{"model":"gpt-oss-120b","input":"Say hello in one sentence."}' | jq '.output[-1].content[0].text'

If the second call returns Authentication failed: Please make sure your API Key is valid, that is AWS, not the gateway. My first Bedrock key had expired. I confirmed it by calling Bedrock directly with the same key and getting the same 403.

Codex supports named profiles, each in its own file. This leaves ~/.codex/config.toml alone.

cat > ~/.codex/agentgateway.config.toml <<EOF
model = "gpt-oss-120b"
model_provider = "agentgateway"

[model_providers.agentgateway]
name = "OpenAI via agentgateway"
base_url = "http://${INGRESS_GW_ADDRESS}/v1"
wire_api = "responses"
EOF

base_url must end in /v1.<base_url>/responses. wire_api = "responses"``env_key.

codex --profile agentgateway

To prove the request took the route you think it did:

codex exec --profile agentgateway --skip-git-repo-check "Reply with exactly: hello from agentgateway"

kubectl --context $CTX logs deployment/agentgateway-proxy -n agentgateway-system --since=5m \
 | grep 'http.path=/v1/responses' | tail -n 3
info request gateway=agentgateway-system/agentgateway-proxy route=internal/llm:request
 endpoint=bedrock-runtime.us-east-2.amazonaws.com:443 http.method=POST http.path=/v1/responses
 http.status=200 protocol=llm gen_ai.provider.name=aws.bedrock
 gen_ai.request.model=openai.gpt-oss-120b-1:0 agw.ai.original_model=gpt-oss-120b

Codex asked for gpt-oss-120b, and Bedrock in us-east-2 served openai.gpt-oss-120b-1:0. I also ran a prompt that needed a tool call ( ls on a directory, then count the files). Codex ran the command and answered correctly, so tool calling survives the Responses-to-Bedrock translation for this model.

Two things you will see in the Codex output that are safe to ignore: a Model metadata for gpt-oss-120b not found warning, because Codex has no built-in entry for that name, and an occasional OutputTextDelta without active item error line. Runs still complete.

The gateway can front MCP servers as well as models. Here it exposes the public Solo.io docs search server at /mcp:

apiVersion: agentgateway.dev/v1alpha1
kind: AgentgatewayBackend
metadata:
 name: solo-search-mcp
 namespace: agentgateway-system
spec:
 mcp:
 targets:
 - name: solo-search
 static:
 host: search.solo.io
 port: 443
 path: /mcp
 policies:
 tls:
 sni: search.solo.io
---
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
 name: solo-search-mcp
 namespace: agentgateway-system
spec:
 parentRefs:
 - name: agentgateway-proxy
 namespace: agentgateway-system
 rules:
 - matches:
 - path:
 type: PathPrefix
 value: /mcp
 backendRefs:
 - name: solo-search-mcp
 group: agentgateway.dev
 kind: AgentgatewayBackend

The HTTPRoute and the AgentgatewayModel share the one listener without conflict. Add the server to the Codex profile:

cat >> ~/.codex/agentgateway.config.toml <<EOF

[mcp_servers.solo-search]
url = "http://${INGRESS_GW_ADDRESS}/mcp"
EOF

Now both the model call and the tool call go through the gateway. In a Codex run you see mcp: solo-search/search started followed by (completed), and in the proxy log each MCP request is tagged protocol=mcp with mcp.method.name=tools/call and mcp.target=solo-search.

The proxy serves its UI on port 15000, bound to localhost inside the pod:

kubectl --context $CTX -n agentgateway-system port-forward deploy/agentgateway-proxy 15000:15000

Open http://localhost:15000/ui and you will not find Logs or Analytics in the sidebar. This cost me some time, so here is the short version:

On Kubernetes, the proxy gets its config from the controller and reports its mode as xds. In that mode the UI shows a “Readonly mode” banner and a fixed, short menu. I checked every value in the v1.7.0 Helm chart and the proxy config schema, and there is no setting that changes it. The pages still work. You have to open them by URL:

http://localhost:15000/ui/llm/logs`` http://localhost:15000/ui/llm/analytics``http://localhost:15000/ui/llm/costs Cost comes from a pricing catalog built into the proxy, with nothing to configure for common models. One Codex turn in my run was 10,084 tokens and about $0.0015. Fifteen calls came to $0.006.

The Models and Routes pages are in the sidebar, and they show what the controller pushed to the proxy:

You can also skip the UI and ask Postgres:

kubectl --context $CTX -n agentgateway-system exec agentgateway-db-0 -- \
 psql -U agentgateway -d agentgateway -c \
 'select started_at, gen_ai_request_model, total_tokens, cost, user_agent_name from request_logs order by started_at desc limit 5'

0.0.0.0. For anything beyond a laptop, add API key or JWT auth on the listener and set kubectl port-forward to port 80 of the proxy gives you a fixed one.request_logs table grows until you prune it.input_schema does not support oneOf, allOf, or anyOf at the top level).

rm ~/.codex/agentgateway.config.toml
pkill cloud-provider-kind
kind delete cluster --name agentgateway-codex

Deleting the cluster deletes the Postgres volume and the logs with it.

The repo has the same build as a 13-step README with all five manifests and a Playwright script that regenerates the screenshots: sebbycorp/agentgateway-oss-k8s.

Related posts:

── more in #ai-agents 4 stories · sorted by recency
── more on @agentgateway 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/deploy-codex-cli-wit…] indexed:0 read:8min 2026-11-18 · —