Updated 2026-08-05
Can an Alibaba Cloud API key power Codex Cloud?
No. Codex Cloud requires ChatGPT sign-in and does not expose the local custom-model-provider setting used by Codex CLI, Desktop, and IDE clients. An ordinary Alibaba Cloud Model Studio API key can power a supported Alibaba model in a local Codex client, but adding that key to a Codex Cloud environment does not reroute the Codex agent itself. This guide separates those two products before you configure anything.
1. The short answer: Cloud and local Codex use different provider paths
OpenAI's authentication documentation separates Codex Cloud from the local clients. The CLI, IDE extension, and desktop app can sign in with ChatGPT or an API key, while Codex Cloud requires ChatGPT sign-in. OpenAI's advanced configuration page then documents custom model providers specifically for local Codex clients.
Alibaba Cloud's Codex instructions follow that local route: they configure a provider in `~/.codex/config.toml`, point it at a Model Studio API Host, and read the key from an environment variable. That configuration file is not a Codex Cloud model-provider control plane.
| Codex surface | Use Alibaba as Codex's model provider? | Reason |
|---|---|---|
| Codex Cloud | No | Cloud requires ChatGPT sign-in and does not expose local custom-provider routing |
| Codex CLI | Yes, for compatible models | Local `config.toml` supports custom providers and a Responses API endpoint |
| Codex desktop app / IDE extension | Yes, when the local client loads the same supported configuration | These are local clients, but the key must be available to the app process |
| Code running inside a Cloud task | Only as an application dependency | A task may call an external API when configured, but that does not change the model running Codex |
Sources checked
- OpenAI Codex authentication - Primary source for the ChatGPT and API-key sign-in matrix, including the Codex Cloud requirement.
- OpenAI Codex advanced configuration - Primary source for local custom model providers, `base_url`, `env_key`, and `wire_api`.
- Alibaba Cloud Model Studio Codex guide - Primary source for Alibaba's local Codex configuration and supported API-key routes.
2. Why a Codex Cloud environment variable does not change the agent model
Codex Cloud environments describe the repository task environment: setup scripts, dependencies, environment variables, and secrets used while preparing or running code. They do not define the provider that powers the Codex agent. OpenAI documents Cloud setup separately from the local `model_provider` configuration.
This means a variable named `DASHSCOPE_API_KEY` or `OPENAI_API_KEY` can be relevant to software inside the repository, but the variable name alone has no routing effect. Treat any claim that 'adding the key to Cloud switches Codex to Alibaba' as incorrect unless OpenAI introduces and documents a Cloud provider-selection feature.
Sources checked
- OpenAI Codex Cloud environments - Primary source for what Cloud environment variables, secrets, and setup scripts control.
- OpenAI Codex Cloud overview - Primary source for the ChatGPT, GitHub, repository, and cloud-environment workflow.
3. What works: use a local Codex custom provider
For Codex CLI, desktop, or an IDE client, choose a model that Alibaba documents as compatible with the Responses API. Then add a uniquely named provider to `~/.codex/config.toml`, use the API Host that belongs to the key's workspace and region, and let `env_key` read the credential from the local environment.
The provider ID matters. OpenAI reserves built-in names including `openai`, `ollama`, and `lmstudio`, so use a distinct ID such as `alibaba-model-studio`. The next guide provides the exact TOML and verification flow.
model = "qwen3.7-max"
model_provider = "alibaba-model-studio"
[model_providers.alibaba-model-studio]
name = "Alibaba Cloud Model Studio"
base_url = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1"
env_key = "DASHSCOPE_API_KEY"
wire_api = "responses"4. Choose the right path before you start
Use Codex Cloud when you want OpenAI's hosted repository workflow and are comfortable using its ChatGPT-backed authentication and model path. Use local Codex when your requirement is specifically to send Codex requests through an Alibaba Cloud Model Studio API key.
If you need both, keep them as two explicit workflows: Cloud for hosted Codex tasks, local Codex for Alibaba-provider sessions. Do not assume a task created in one surface will preserve the provider routing of the other.
| Requirement | Recommended surface |
|---|---|
| Hosted task that runs against a GitHub repository | Codex Cloud with ChatGPT sign-in |
| Use an Alibaba API key as the agent's model credential | Local Codex CLI, desktop, or IDE client |
| Call Alibaba from application code during a task | Configure the application separately; do not confuse it with Codex routing |
| Share one workflow across a team | Standardize the local config template and distribute credentials through an approved secret channel |
5. Confirm the key class before using the setup guide
This article series covers ordinary Alibaba Cloud Model Studio API keys, including current workspace keys commonly beginning with `sk-ws` and supported legacy keys beginning with `sk-`. It does not describe Token Plan or Coding Plan credentials such as `sk-sp`, and it does not define how a reseller should allocate, deliver, rotate, or revoke keys.
Before setup, record the key's region, workspace, API Host, allowed models, and any IP restrictions. Key shape is only a hint; the console's workspace and permission settings are the source of truth.
Sources checked
- Alibaba Cloud Model Studio API key guide - Primary source for workspace keys, API Hosts, permissions, regions, and key lifecycle.
FAQ
Can I paste an Alibaba API key into Codex Cloud and make it use Qwen?
No. Codex Cloud requires ChatGPT sign-in and does not expose the local custom-provider setting. Use a local Codex client for Alibaba provider routing.
Does a Cloud environment variable change the model that powers Codex?
No. Cloud environment configuration affects the task environment or code being run; it is not the Codex model-provider selector.
Can the Codex CLI use an ordinary Alibaba Model Studio API key?
Yes, when the key, workspace API Host, region, model, and Responses API support all match the Alibaba configuration.
Is this guide for Alibaba Token Plan or Coding Plan keys?
No. It covers ordinary Model Studio API keys. Plan-specific credentials use different endpoints and entitlements.
Will a local custom provider carry over when I send a task to Codex Cloud?
No. Treat Cloud and local provider routing as separate workflows.
An Alibaba Cloud Model Studio API key belongs in a local Codex custom-provider workflow, not in Codex Cloud's model path. Keep Cloud for its ChatGPT-authenticated hosted workflow, and continue to the local setup guide when Alibaba routing is the actual requirement.
Related model comparisons
Continue from this guide into structured DeepSeek-first comparison pages with model tables, routing advice, and pricing context.