{"slug": "deploy-codex-cli-with-bedrock-through-agentgateway", "title": "Deploy Codex CLI with Bedrock Through agentgateway", "summary": "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.", "body_md": "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.\n\nAll of it runs on open source [agentgateway](https://agentgateway.dev) v1.7.0 in a local kind cluster. The manifests and the full step list are in [sebbycorp/agentgateway-oss-k8s](https://github.com/sebbycorp/agentgateway-oss-k8s).\n\nWhat you end up with:\n\n`gpt-oss-120b`. The gateway rewrites that to Bedrock’s `openai.gpt-oss-120b-1:0`. Any other model name gets a 404.`/mcp`.\n\n``` php\nflowchart LR\nC[Codex CLI<br/>no API key] -->|/v1/responses| LB[cloud-provider-kind<br/>localhost port]\nC -->|/mcp| LB\nLB --> P[agentgateway proxy]\nP -->|Converse + Bedrock API key| B[Amazon Bedrock<br/>openai.gpt-oss-120b-1:0]\nP -->|streamable HTTP| M[search.solo.io/mcp]\nP -->|request log| DB[(Postgres)]\nDB --> UI[agentgateway UI<br/>Logs / Analytics]\n```\n\nCodex speaks the OpenAI Responses API. Bedrock does not. agentgateway translates between the two, which is the part that makes this work without touching Codex.\n\n`kind`, `kubectl`, `helm`, `jq`, `openssl`` cloud-provider-kind``us-east-2`)\n\n```\nexport BEDROCK_API_KEY='<your Bedrock API key>'\nexport CTX=kind-agentgateway-codex\n```\n\nEvery 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.\n\n```\nkind create cluster --name agentgateway-codex\n```\n\nIn a second terminal, start cloud-provider-kind and leave it running:\n\n```\ncloud-provider-kind --gateway-channel disabled --enable-lb-port-mapping\n```\n\nTwo flags, both needed on a Mac:\n\n`--gateway-channel disabled``--enable-lb-port-mapping`` sudo` required. Without it (and without `` please run this again with `sudo` `` .\nGateway API CRDs first, then two Helm releases: the agentgateway CRDs and the controller.\n\n```\nkubectl --context $CTX apply --server-side --force-conflicts \\\n -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.6.3/standard-install.yaml\n\nhelm upgrade -i agentgateway-crds oci://cr.agentgateway.dev/charts/agentgateway-crds \\\n --kube-context $CTX --create-namespace --namespace agentgateway-system --version v1.7.0\n\nhelm upgrade -i agentgateway oci://cr.agentgateway.dev/charts/agentgateway \\\n --kube-context $CTX --namespace agentgateway-system --version v1.7.0 \\\n --set controller.image.pullPolicy=Always --wait\n```\n\nHelm only installs the controller. The proxy itself is created later, by the controller, when it sees a `Gateway` resource. That matters in step 4.\n\nagentgateway 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.\n\n```\nkubectl --context $CTX -n agentgateway-system create secret generic agentgateway-db \\\n --from-literal=password=\"$(openssl rand -hex 24)\"\napiVersion: v1\nkind: Service\nmetadata:\n name: agentgateway-db\n namespace: agentgateway-system\nspec:\n clusterIP: None\n selector:\n app: agentgateway-db\n ports:\n - name: postgres\n port: 5432\n---\napiVersion: apps/v1\nkind: StatefulSet\nmetadata:\n name: agentgateway-db\n namespace: agentgateway-system\nspec:\n serviceName: agentgateway-db\n replicas: 1\n selector:\n matchLabels:\n app: agentgateway-db\n template:\n metadata:\n labels:\n app: agentgateway-db\n spec:\n containers:\n - name: postgres\n image: postgres:17\n ports:\n - containerPort: 5432\n name: postgres\n env:\n - name: POSTGRES_DB\n value: agentgateway\n - name: POSTGRES_USER\n value: agentgateway\n - name: POSTGRES_PASSWORD\n valueFrom:\n secretKeyRef:\n name: agentgateway-db\n key: password\n - name: PGDATA\n value: /var/lib/postgresql/data/pgdata\n readinessProbe:\n exec:\n command: [\"pg_isready\", \"-U\", \"agentgateway\", \"-d\", \"agentgateway\"]\n periodSeconds: 5\n volumeMounts:\n - name: data\n mountPath: /var/lib/postgresql/data\n volumeClaimTemplates:\n - metadata:\n name: data\n spec:\n accessModes: [\"ReadWriteOnce\"]\n resources:\n requests:\n storage: 5Gi\n```\n\nThe 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`:\n\n```\napiVersion: agentgateway.dev/v1alpha1\nkind: AgentgatewayParameters\nmetadata:\n name: agentgateway-proxy-params\n namespace: agentgateway-system\nspec:\n rawConfig:\n config:\n database:\n url: \"postgres://agentgateway:${PG_PASSWORD}@agentgateway-db.agentgateway-system.svc.cluster.local:5432/agentgateway\"\n```\n\n`${PG_PASSWORD}` is a placeholder so the password stays out of git. Substitute it when you apply:\n\n```\nPG_PASSWORD=$(kubectl --context $CTX -n agentgateway-system get secret agentgateway-db \\\n -o jsonpath='{.data.password}' | base64 -d)\nsed \"s/\\${PG_PASSWORD}/$PG_PASSWORD/\" 04-gateway-parameters.yaml | kubectl --context $CTX apply -f -\n```\n\nOne 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.\n\n```\napiVersion: gateway.networking.k8s.io/v1\nkind: Gateway\nmetadata:\n name: agentgateway-proxy\n namespace: agentgateway-system\nspec:\n gatewayClassName: agentgateway\n listeners:\n - protocol: HTTP\n port: 80\n name: http\n allowedRoutes:\n namespaces:\n from: All\n kinds:\n - group: gateway.networking.k8s.io\n kind: HTTPRoute\n - group: agentgateway.dev\n kind: AgentgatewayModel\n infrastructure:\n parametersRef:\n group: agentgateway.dev\n kind: AgentgatewayParameters\n name: agentgateway-proxy-params\n```\n\nTwo things in here are easy to miss:\n\n`kinds` must list `AgentgatewayModel`` parametersRef` must point at something that exists.`Programmed=False` and no proxy was created. Apply step 3 first.\nStore the Bedrock key, then publish the model.\n\n```\nkubectl --context $CTX -n agentgateway-system create secret generic bedrock-secret \\\n --from-literal=Authorization=\"$BEDROCK_API_KEY\"\napiVersion: agentgateway.dev/v1alpha1\nkind: AgentgatewayModel\nmetadata:\n name: gpt-oss-120b\n namespace: agentgateway-system\nspec:\n parentRefs:\n - group: gateway.networking.k8s.io\n kind: Gateway\n name: agentgateway-proxy\n sectionName: http\n provider: Bedrock\n bedrock:\n region: us-east-2\n policies:\n auth:\n secretRef:\n name: bedrock-secret\n transformations:\n - field: model\n expression: '\"openai.gpt-oss-120b-1:0\"'\n```\n\nHow this reads:\n\n`metadata.name` is the model name clients use.`model` transformation is what Bedrock receives.`policies.auth.secretRef` is for a Bedrock API key`policies.auth.aws.secretRef`, which is for IAM access keys, and the model reported `accessKey is missing or not a valid string`.\nFind the port cloud-provider-kind published:\n\n```\nexport INGRESS_GW_ADDRESS=localhost:$(docker port $(docker ps --filter name=kindccm -q) 80/tcp | head -1 | awk -F: '{print $NF}')\n```\n\nNo `Authorization` header on either call. The gateway adds it.\n\n```\ncurl -s \"http://$INGRESS_GW_ADDRESS/v1/models\" | jq -r '.data[].id'\n# gpt-oss-120b\n\ncurl -s \"http://$INGRESS_GW_ADDRESS/v1/responses\" -H content-type:application/json \\\n -d '{\"model\":\"gpt-oss-120b\",\"input\":\"Say hello in one sentence.\"}' | jq '.output[-1].content[0].text'\n```\n\nIf 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.\n\nCodex supports named profiles, each in its own file. This leaves `~/.codex/config.toml` alone.\n\n```\ncat > ~/.codex/agentgateway.config.toml <<EOF\nmodel = \"gpt-oss-120b\"\nmodel_provider = \"agentgateway\"\n\n[model_providers.agentgateway]\nname = \"OpenAI via agentgateway\"\nbase_url = \"http://${INGRESS_GW_ADDRESS}/v1\"\nwire_api = \"responses\"\nEOF\n```\n\n`base_url` must end in `/v1`.`<base_url>/responses`.` wire_api = \"responses\"``env_key`.\n\n```\ncodex --profile agentgateway\n```\n\nTo prove the request took the route you think it did:\n\n```\ncodex exec --profile agentgateway --skip-git-repo-check \"Reply with exactly: hello from agentgateway\"\n\nkubectl --context $CTX logs deployment/agentgateway-proxy -n agentgateway-system --since=5m \\\n | grep 'http.path=/v1/responses' | tail -n 3\ninfo request gateway=agentgateway-system/agentgateway-proxy route=internal/llm:request\n endpoint=bedrock-runtime.us-east-2.amazonaws.com:443 http.method=POST http.path=/v1/responses\n http.status=200 protocol=llm gen_ai.provider.name=aws.bedrock\n gen_ai.request.model=openai.gpt-oss-120b-1:0 agw.ai.original_model=gpt-oss-120b\n```\n\nCodex 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.\n\nTwo 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.\n\nThe gateway can front MCP servers as well as models. Here it exposes the public Solo.io docs search server at `/mcp`:\n\n```\napiVersion: agentgateway.dev/v1alpha1\nkind: AgentgatewayBackend\nmetadata:\n name: solo-search-mcp\n namespace: agentgateway-system\nspec:\n mcp:\n targets:\n - name: solo-search\n static:\n host: search.solo.io\n port: 443\n path: /mcp\n policies:\n tls:\n sni: search.solo.io\n---\napiVersion: gateway.networking.k8s.io/v1\nkind: HTTPRoute\nmetadata:\n name: solo-search-mcp\n namespace: agentgateway-system\nspec:\n parentRefs:\n - name: agentgateway-proxy\n namespace: agentgateway-system\n rules:\n - matches:\n - path:\n type: PathPrefix\n value: /mcp\n backendRefs:\n - name: solo-search-mcp\n group: agentgateway.dev\n kind: AgentgatewayBackend\n```\n\nThe `HTTPRoute` and the `AgentgatewayModel` share the one listener without conflict. Add the server to the Codex profile:\n\n```\ncat >> ~/.codex/agentgateway.config.toml <<EOF\n\n[mcp_servers.solo-search]\nurl = \"http://${INGRESS_GW_ADDRESS}/mcp\"\nEOF\n```\n\nNow 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`.\n\nThe proxy serves its UI on port 15000, bound to localhost inside the pod:\n\n```\nkubectl --context $CTX -n agentgateway-system port-forward deploy/agentgateway-proxy 15000:15000\n```\n\nOpen `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:\n\nOn 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:**\n\n`http://localhost:15000/ui/llm/logs`` http://localhost:15000/ui/llm/analytics``http://localhost:15000/ui/llm/costs`\nCost 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.\n\nThe Models and Routes pages are in the sidebar, and they show what the controller pushed to the proxy:\n\nYou can also skip the UI and ask Postgres:\n\n```\nkubectl --context $CTX -n agentgateway-system exec agentgateway-db-0 -- \\\n psql -U agentgateway -d agentgateway -c \\\n 'select started_at, gen_ai_request_model, total_tokens, cost, user_agent_name from request_logs order by started_at desc limit 5'\n```\n\n`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`). \n\n```\nrm ~/.codex/agentgateway.config.toml\npkill cloud-provider-kind\nkind delete cluster --name agentgateway-codex\n```\n\nDeleting the cluster deletes the Postgres volume and the logs with it.\n\nThe 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](https://github.com/sebbycorp/agentgateway-oss-k8s).\n\nRelated posts:", "url": "https://wpnews.pro/news/deploy-codex-cli-with-bedrock-through-agentgateway", "canonical_source": "https://agentgateway.dev/blog/2026-11-18-deploy-codex-cli-bedrock-agentgateway/", "published_at": "2026-11-18 00:00:00+00:00", "updated_at": "2026-11-19 03:12:05.010634+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "agent-protocols", "large-language-models", "developer-tools"], "entities": ["agentgateway", "Codex CLI", "Amazon Bedrock", "OpenAI", "sebbycorp", "gpt-oss-120b", "Postgres", "Kubernetes Gateway API"], "also_reported_by": [], "takeaway": "Point Codex CLI at a local agentgateway v1.7.0 endpoint with no API key and let the gateway rewrite gpt-oss-120b to Bedrock's openai.gpt-oss-120b-1:0, translating OpenAI Responses API calls into Bedrock Converse calls while logging token counts and cost to Postgres.", "recommendation": {"advice": "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.", "playbook": "inference-serving", "playbook_url": "https://wpnews.pro/playbooks/inference-serving"}, "alternates": {"html": "https://wpnews.pro/news/deploy-codex-cli-with-bedrock-through-agentgateway", "markdown": "https://wpnews.pro/news/deploy-codex-cli-with-bedrock-through-agentgateway.md", "text": "https://wpnews.pro/news/deploy-codex-cli-with-bedrock-through-agentgateway.txt", "jsonld": "https://wpnews.pro/news/deploy-codex-cli-with-bedrock-through-agentgateway.jsonld"}}