D1V PAI with CC-Switch and AI CLI clients
Create a project-scoped D1V PAI key in the Dashboard, then use the same OpenAI-compatible endpoint safely with Codex, Claude Code through CC-Switch routing, and other supported clients.
Recommended paths
D1V PAI exposes an OpenAI-compatible endpoint. The recommended setup depends on the client protocol:
- Codex + CC-Switch: supported directly with the Responses API. This is the simplest path.
- Claude Code + CC-Switch: supported through CC-Switch local routing, which converts Anthropic Messages requests to OpenAI Responses requests. Use CC Switch
3.17.0or newer. - CC-Switch CLI/TUI: supported for terminal, SSH, and automation workflows.
- OpenAI-compatible clients: AionUI, OpenCode, Grok Build, WorkBuddy, OpenClaw, and Hermes can use the same Base URL and key when configured for an OpenAI-compatible provider.
Do not point Claude Code directly at D1V_PAI_BASE_URL as an Anthropic endpoint. Claude Code sends /v1/messages, while D1V PAI is provisioned as an OpenAI-compatible gateway. Use the CC-Switch routing instructions below.
Create a project-scoped key in Dashboard
- Sign in and open Dashboard.
- Wait until the workspace status is ready.
- Click Create Project Environment in the Dashboard toolbar.
- Enter a name for the environment and keep D1V PAI selected. Other integrations are optional.
- Click Create project environment.
- When the environment is ready, copy these two values:
D1V_PAI_BASE_URL: the OpenAI-compatible API URL, normallyhttps://pai.d1v.ai/v1.D1V_PAI_API_KEY: a secret API key scoped to this project environment.
The values are displayed in full after creation and remain manageable in the project. Use the project key for model calls; do not use or request a platform administration key.
Verify the endpoint and discover models
Keep the values in environment variables while testing:
export D1V_PAI_BASE_URL='https://pai.d1v.ai/v1'
export D1V_PAI_API_KEY='<paste-project-key>'
curl "$D1V_PAI_BASE_URL/models" \
-H "Authorization: Bearer $D1V_PAI_API_KEY"A successful response contains model IDs under data. Choose a model from this response instead of copying a model name from an old screenshot or third-party tutorial.
Install and initialize the local tools
Install Node.js first, then install and initialize the CLIs you intend to use:
node --version
npm --version
npm install -g @openai/codex@latest
npm install -g @anthropic-ai/claude-code@latest
codex --help
claude --helpRunning the help commands once creates the local configuration directories that CC-Switch manages. If you only need Codex, Claude Code is optional.
Install CC-Switch
Download the current desktop release from CC-Switch Releases. On macOS you can also use:
brew tap farion1231/ccswitch
brew install --cask cc-switchOpen CC-Switch after installation. This guide uses a Custom provider because the built-in PackyCode preset contains PackyAPI endpoints, not D1V PAI endpoints.
Configure Codex in CC-Switch
- Open the Codex tab and click + to add an application-specific provider.
- Keep the Custom preset and name it
D1V PAI. - Set API Key to the value of
D1V_PAI_API_KEY. - Set API request URL / Base URL to the exact value of
D1V_PAI_BASE_URL(https://pai.d1v.ai/v1). - Set Upstream/API format to native Responses.
- Fetch models from the endpoint or enter a model ID returned by
/modelsas the default model. - Save the provider, click Enable, open a new terminal, and run
codex.If you prefer to inspect the generated configuration, it is equivalent to:
model_provider = "d1v_pai"
model = "<model-id-from-v1-models>"
disable_response_storage = true
[model_providers.d1v_pai]
name = "D1V PAI"
base_url = "https://pai.d1v.ai/v1"
wire_api = "responses"
requires_openai_auth = trueAnd ~/.codex/auth.json contains:
{
"OPENAI_API_KEY": "<D1V_PAI_API_KEY>"
}Configure Claude Code through CC-Switch routing
Claude Code requires protocol conversion. Use CC Switch 3.17.0 or newer:
- Open the Claude Code tab, click +, and keep the Custom preset.
- Name the provider
D1V PAIand pasteD1V_PAI_API_KEYinto API Key. - Set Request URL to
https://pai.d1v.ai. This is the service root derived by removing the trailing/v1fromD1V_PAI_BASE_URL. - Expand Advanced options and select OpenAI Responses API (routing required).
- Keep the authentication field on
ANTHROPIC_AUTH_TOKEN (Authorization), so the route sendsAuthorization: Bearer <key>upstream. - Map at least the default fallback model to a model ID returned by D1V PAI
/models. You may map Sonnet/Opus to the same main model and Haiku to a smaller model. - Open Settings → Routing → Local routing, enable the routing service, then enable routing for Claude Code.
- Enable the D1V PAI provider, close any running Claude Code process, open a new terminal, and run
claude.The local route normally listens on
127.0.0.1:15721. CC-Switch keeps the real project key in its provider store and writes only the local route into Claude Code live configuration.
Use CC-Switch CLI or TUI
CC-Switch CLI is useful on servers, over SSH, and in automation:
curl -fsSL https://github.com/SaladDay/cc-switch-cli/releases/latest/download/install.sh | bash
cc-switch env tools
cc-switch env check
cc-switch --app codexIn the TUI, add a custom Codex provider using the same Base URL, API Key, Responses format, and model ID described above. For Claude Code, run cc-switch --app claude, configure the custom Responses provider, and enable local routing before testing.
On macOS or Linux, enable the daemon-managed Claude route with:
cc-switch --app claude proxy enable
cc-switch proxy showOn Windows, run the route in the foreground because daemon-managed proxy sessions require Unix domain sockets:
cc-switch proxy serve --takeover claudeUseful checks:
cc-switch --app codex provider current
cc-switch --app codex provider list
cc-switch --app codex env check
cc-switch --app claude env checkOther clients worth supporting
For clients with a custom OpenAI-compatible provider, use the same four values:
- Provider/API format: OpenAI compatible
- Base URL:
D1V_PAI_BASE_URL - API Key:
D1V_PAI_API_KEY - Model: an ID returned by
GET /models
This applies directly to AionUI, OpenCode, Grok Build, and WorkBuddy. OpenClaw and Hermes are also good candidates when configured through their CC-Switch tabs with an OpenAI-compatible provider.
We do not make Claude Desktop part of the primary setup because it requires additional local routing and model-role mapping. We also keep Claude cache optimization proxy out of this guide: it is an optional performance layer, not required to obtain or validate D1V PAI access.
Troubleshooting and key safety
- 401/403: confirm you copied
D1V_PAI_API_KEY, not a D1V account API key or platform administration key. - 404 or wrong endpoint: Codex and OpenAI-compatible clients use the
/v1Base URL. Claude Code must use CC-Switch routing and the OpenAI Responses format. - Model not found: refresh
GET /modelswith the same project key and use an exact returned ID. - Provider switch did not take effect: initialize the target CLI once, enable the provider again, and start a new terminal process.
- Environment overrides configuration: run
cc-switch --app codex env checkorcc-switch --app claude env checkand remove conflictingOPENAI_API_KEY,ANTHROPIC_API_KEY, or Base URL variables.
Never commit the project key to Git, paste it into screenshots, or place it in client-side browser code. Create a separate project environment when you need separate usage tracking or revocation boundaries.
References and version notes
- CC-Switch releases
- CC-Switch provider manual
- PackyAPI CC-Switch common steps
- PackyAPI CC-Switch CLI guide
CC-Switch changes quickly. Field names may move between releases; preserve the protocol choices and values described here even if the form layout changes.