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.

Where an Alibaba Cloud Model Studio API key fits
Codex surfaceUse Alibaba as Codex's model provider?Reason
Codex CloudNoCloud requires ChatGPT sign-in and does not expose local custom-provider routing
Codex CLIYes, for compatible modelsLocal `config.toml` supports custom providers and a Responses API endpoint
Codex desktop app / IDE extensionYes, when the local client loads the same supported configurationThese are local clients, but the key must be available to the app process
Code running inside a Cloud taskOnly as an application dependencyA task may call an external API when configured, but that does not change the model running Codex

Sources checked

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

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.

Decision path
RequirementRecommended surface
Hosted task that runs against a GitHub repositoryCodex Cloud with ChatGPT sign-in
Use an Alibaba API key as the agent's model credentialLocal Codex CLI, desktop, or IDE client
Call Alibaba from application code during a taskConfigure the application separately; do not confuse it with Codex routing
Share one workflow across a teamStandardize 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

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.