This topic describes how to use Codex CLI and Codex App through the OceanBase MaaS gateway.
Configuration instructions
Codex is a coding agent developed by OpenAI and supports the following two forms:
- Codex CLI: An open-source command-line tool that can read, modify, and run code in a local terminal.
- Codex App: A ready-to-use graphical desktop application.
Codex CLI and Codex App share the ~/.codex/config.toml configuration file and related environment variables. You only need to configure them once for use with both the CLI and App.
After connecting through the OceanBase MaaS gateway, you can use GPT, Codex, and other model families without directly accessing the official OpenAI API.
Item |
Value |
|---|---|
| Gateway URL | https://ai-api-g.oceanbase.com/api/v1 |
| Protocol | OpenAI Responses API (recommended) |
| Authentication | The API key issued by MaaS (sk_prefix). For more information, see Manage AI API keys |
Note
OpenAI positions the Responses API as its next-generation unified interface. Codex recommends using this interface by configuring wire_api = "responses". The Chat Completions API is retained only for compatibility with existing applications and integrations and is not recommended for new Codex integrations. The MaaS gateway supports /api/v1/responses.
Install Codex
Install Codex CLI globally using npm.
npm install -g @openai/codex
After installation, run codex --version to verify the installation.
Download the Codex App installer for your platform from the OpenAI official website, and follow the instructions to install it.
Codex App automatically reads ~/.codex/config.toml when it starts for the first time. Complete the following configuration before starting Codex App.
Configuration steps
Obtain MaaS API Key
Apply for an API key in the OceanBase MaaS console or through your internal process. The API key typically follows the format sk_xxxx. Store the API key securely and never commit it to a code repository. For specific procedures, see Manage AI API Keys.
Configure shell environment variables (Recommended)
Add the API key to your shell configuration file so that Codex can read it automatically each time it starts.
- Identify the shell you are using.
echo "$SHELL"
- If the output is
/bin/zsh, open~/.zshrcin an editor, such as by runningnano ~/.zshrcorvim ~/.zshrc. - If the output is
/bin/bash, open~/.bashrcin an editor, such as by runningnano ~/.bashrcorvim ~/.bashrc.
- Open the shell configuration file. The following example uses zsh. Append the following content to the end of the file.
Note
Replace sk_xxxx with the actual API key obtained from the MaaS console. For information about how to obtain API Key, see Manage AI API keys.
# ============= OceanBase MaaS + Codex Configuration ============
export MAAS_API_KEY="sk_xxxx" # Replace with your MaaS API Key
Apply the configuration.
source ~/.zshrc # zsh # Or source ~/.bashrc # bash
Configure Codex
Edit the Codex configuration file to specify the MaaS gateway as the model provider.
- If the ~/.codex directory does not exist, create it first.
mkdir -p ~/.codex
- Use an editor to create or open
~/.codex/config.toml, such as by runningnano ~/.codex/config.tomlorvim ~/.codex/config.toml, and add the following content.
model_provider = "maas"
model = "gpt-5.3-codex"
[model_providers.maas]
name = "OceanBase MaaS"
base_url = "https://ai-api-g.oceanbase.com/api/v1"
env_key = "MAAS_API_KEY"
wire_api = "responses"
The following table describes the configuration fields.
Parameter |
Description |
|---|---|
model_provider |
Specifies MaaS as the model provider. |
model |
Specifies the model to use. For more information, see Supported models. |
base_url |
The MaaS OpenAI-compatible endpoint, including /api/v1. |
env_key |
The name of the environment variable that stores the API key. |
wire_api |
Uses the Responses API. |
Start Codex
Load the environment variables, navigate to your project directory, and start Codex CLI.
source ~/.zshrc # zsh
# Or
source ~/.bashrc # bash
cd /path/to/your/project
codex
Start Codex App directly. The application automatically reads ~/.codex/config.toml. If Codex App is already running, restart it after modifying the configuration.
Note
When you start Codex App for the first time, if you are prompted to enter an API key, enter your MaaS API key and close the application. Then, edit ~/.codex/config.toml as described above and restart Codex App to persist the configuration.
Supported models
To switch models, modify the model field in config.toml. No other configuration changes are required.
GPT and Codex model families (Native model names recommended)
For GPT and Codex models, we recommend using native model names, such as gpt-5.3-codex, so that Codex can correctly identify the model and enable reasoning capabilities and other dedicated features.
# Recommended: Native alias, full features
model = "gpt-5.3-codex"
# Not recommended: A complete ID with a vendor prefix may cause silent feature degradation.
model = "openai/gpt-5.3-codex"
The following table lists the GPT and Codex models currently supported by the MaaS gateway. The actual response from the /api/v1/models endpoint shall prevail.
Model |
Description |
|---|---|
gpt-5.3-codex |
Primary Codex model (recommended). |
gpt-5.2-codex |
Previous-generation Codex model. |
gpt-5.4 |
General-purpose GPT model. |
gpt-5.4-pro |
High-performance GPT model. |
gpt-5.4-mini |
Lightweight GPT model. |
Verify connection
After completing the configuration, verify the environment variables, gateway connectivity, and model invocation in sequence.
Check environment variables
Confirm that the API key has been added to the shell configuration file and loaded into the current terminal environment.
echo $MAAS_API_KEY
Test gateway connectivity
Send a request to the MaaS gateway to verify network connectivity and the validity of the API key.
curl -s https://ai-api-g.oceanbase.com/api/v1/models \
-H "Authorization: Bearer $MAAS_API_KEY" | head -c 500
Test Responses API
Send a minimal Responses API request to verify the complete model invocation path.
curl -s https://ai-api-g.oceanbase.com/api/v1/responses \
-H "Authorization: Bearer $MAAS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.3-codex",
"input": "say ok",
"max_output_tokens": 16
}'
If the gateway returns HTTP 200 and the response contains output text, the configuration is correct.
Troubleshooting
API Key invalid or authentication failed
Run
echo $MAAS_API_KEYto confirm thatMAAS_API_KEYis set.Confirm that the API key begins with
sk_and does not contain extra spaces or newline characters.Confirm that the API key is enabled in the MaaS console.
Reload the configuration based on your current shell.
source ~/.zshrc # zsh
# Or
source ~/.bashrc # bash
Connection failure
- Check whether your network can access
ai-api-g.oceanbase.com. - Confirm that
base_url in config.tomlis set tohttps://ai-api-g.oceanbase.com/api/v1. The URL must include/api/v1. - Check whether a firewall or proxy is blocking outbound connections.
Environment variables not taking effect
- Open a new terminal, or run
source ~/.zshrc/source ~/.bashrc. - Run
echo "$SHELL"and confirm that the API key was added to the configuration file for your current shell.
Configuration file not taking effect
- Confirm that the configuration file path is
~/.codex/config.toml. - Run
cat ~/.codex/config.tomlto view the configuration file. - If the directory does not exist, run
mkdir -p ~/.codexfirst. - Restart Codex App after modifying the configuration.
Model unavailable
- Call
/api/v1/modelsendpoint and confirm that the response contains the target model. - Confirm that the value of the
modelfield exactly matches theidin the model list. - For GPT and Codex models, use native model names whenever possible, such as
gpt-5.3-codex. max_output_tokensin a Responses API request must be greater than or equal to 16.
