/install litellm-vertex-codex
LiteLLM to Vertex AI Setup for Codex
This skill describes how to configure the OpenAI Codex CLI agent to communicate with Google's Vertex AI Gemini models using LiteLLM as a protocol translation proxy.
Codex requires a strict OpenAI response format and specific roles (user, assistant/model) which native Gemini or lightweight proxies (like CLIProxyAPI) do not perfectly support. LiteLLM is required to strip unsupported parameters and format the requests.
Prerequisites
codexCLI installed (npm install -g @openai/codex)litellminstalled and running locally- Google Cloud Platform (GCP) Project ID with Vertex AI API enabled
- Vertex AI authentication configured (e.g., Application Default Credentials)
1. LiteLLM Configuration
You need to create a config.yaml for LiteLLM that drops complex parameters and sets content to simple strings, then routes a codex model alias to your Gemini Vertex endpoint.
Create or update your config.yaml (e.g., /app/config.yaml):
litellm_settings:
drop_params: true
set_content_to_str: true # Crucial for Codex: forces complex system prompts into simple strings
model_list:
- model_name: gemini-3.1-pro-preview
litellm_params:
model: vertex_ai/gemini-3.1-pro-preview
vertex_project: your-gcp-project-id
vertex_location: global
drop_params: true
# Create aliases for Codex to use
- model_name: codex
litellm_params:
model: vertex_ai/gemini-3.1-pro-preview
vertex_project: your-gcp-project-id
vertex_location: global
drop_params: true
Run LiteLLM with this config (e.g., litellm --config /app/config.yaml --port 4000).
2. Codex Configuration
Codex stores its configuration in ~/.codex/config.toml. You must configure it to point to your local LiteLLM instance and specifically request the responses wire API, as Codex has deprecated the chat wire API.
Update ~/.codex/config.toml:
# Use the custom LiteLLM provider
model_provider = "litellm"
# The model name here MUST match the `model_name` in your LiteLLM config
model = "gemini-3.1-pro-preview"
model_reasoning_effort = "high"
[model_providers.litellm]
name = "litellm"
# Point to your local LiteLLM instance
base_url = "http://127.0.0.1:4000/v1"
# Crucial: Codex will error out if this is set to "chat"
wire_api = "responses"
[projects."/path/to/your/workspace"]
trust_level = "trusted"
3. Shell Environment
Codex expects OPENAI_API_KEY to be set, even when using a custom proxy that doesn't require an actual OpenAI key.
Add this to your shell profile (~/.bashrc or ~/.zshrc):
export OPENAI_API_KEY="sk-litellm"
4. Verification
To verify the setup is working, run Codex in a temporary git repository (Codex refuses to run outside a git repo):
cd $(mktemp -d) && git init && codex exec 'hello'
If successful, Gemini will respond via the Codex CLI interface.
Troubleshooting
wire_api = "chat"is no longer supported: Ensurewire_api = "responses"is set in~/.codex/config.toml.Please use a valid role: user, model.: This means your proxy isn't correctly translating the OpenAIassistantorsystemroles to Gemini's expected format. Ensure you are using LiteLLM (not CLIProxyAPI) and thatset_content_to_str: trueis enabled in LiteLLM config.- Hanging Commands / No Output: Ensure
pty=trueis used if calling Codex programmatically via Hermes, or that you are running it in an interactive terminal.
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install litellm-vertex-codex - 安装完成后,直接呼叫该 Skill 的名称或使用
/litellm-vertex-codex触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Src 是什么?
Configure OpenAI Codex CLI to use Vertex AI Gemini models via LiteLLM. A guide for translating strict Codex requests for Gemini compatibility. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 50 次。
如何安装 Src?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install litellm-vertex-codex」即可一键安装,无需额外配置。
Src 是免费的吗?
是的,Src 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Src 支持哪些平台?
Src 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Src?
由 bhrum(@bhrum)开发并维护,当前版本 v1.0.0。