AI Gateway Model Management: cz-cli Command Line Operations
AI Gateway model management is typically handled through the Studio UI, but cz-cli provides a corresponding command-line interface — for creating and configuring virtual Keys, browsing available models, and registering them as cz-cli Agent LLMs. It is well suited for automation scripts and CI/CD pipelines, as well as quickly querying model lists from the terminal.
Core Flow
Commands Overview
| Command | Purpose |
|---|---|
cz-cli ai-gateway key list | List all virtual Keys |
cz-cli ai-gateway key create | Create a virtual Key |
cz-cli ai-gateway key upsert | Create or update a Key (idempotent, recommended) |
cz-cli ai-gateway key get | Retrieve the full Key value |
cz-cli ai-gateway key enable/disable | Enable or disable a Key |
cz-cli ai-gateway key delete | Delete a Key |
cz-cli ai-gateway key set-quota | Set the token quota for a Key |
cz-cli ai-gateway model list | View models accessible with a Key |
cz-cli agent llm add ... --provider clickzetta | Register a Key as an Agent LLM |
Managing Virtual Keys
List Existing Keys
| Field | Description |
|---|---|
id | Unique ID of the Key |
alias | Key alias, specified at creation time |
vApiKey | Key value, shown masked (first 4 + last 4 characters). The full value is required for all subsequent operations; the masked value and alias cannot be used |
status | 1 = enabled, 0 = disabled |
Create a Key
Create or Update a Key (upsert, recommended)
upsert is idempotent — if the Key already exists it updates the configuration, if it does not exist it creates one. Suitable for repeated execution in scripts:
upsert parameter descriptions:
| Parameter | Description |
|---|---|
--quota | Token quota value |
--period | Quota period: daily / weekly / monthly / total (long-term) |
--route-type | Routing rule: default (built-in models) / provider (specific provider) / byok (bring your own key) |
--providers | Specify provider IDs (used when route-type=provider) |
--provider-sort | Sorting strategy (used when route-type=default): price / throughput / latency |
--private-keys | List of BYOK Key aliases (used when route-type=byok) |
--add-to-llm | Automatically register as [llm.<name>] in ~/.clickzetta/profiles.toml, using alias as value |
--use | Also set as the active LLM |
Update Quota
Enable / Disable / Delete
| Operation | Output |
|---|---|
| disable | {"data": {"id": 738, "status": 0}} |
| enable | {"data": {"id": 738, "status": 1}} |
| delete | {"data": {"id": 738, "deleted": true}} |
Browsing Available Models
The output is the list of models visible to that Key, in the following format (the actual response returns 42 models):
| Field | Description |
|---|---|
modelIdentifier | Unique model identifier, e.g., deepseek/deepseek-v4-pro, used in AI_COMPLETE() |
modelName | Display name of the model, e.g., DeepSeek V4 Pro |
modelInvokeStatus | 1 = callable |
The model identifier format is <provider>/<model-name>, which is the full name used in AI_COMPLETE calls.
Registering as an Agent LLM
The built-in AI Agent in cz-cli requires an LLM backend. A virtual Key from AI Gateway can be used as the Agent LLM.
Option 1: Complete in One Step with upsert
--add-to-llm writes the Key into the [llm.my_agent] section of ~/.clickzetta/profiles.toml, and --use sets it as the default LLM.
Option 2: Manual Registration
Retrieve the full Key value with key get, then add it manually:
When provider is clickzetta, --base-url must be set to the AI Gateway Base URL.
AI Gateway Base URL by region:
| Region | Base URL |
|---|---|
| Alibaba Cloud Shanghai | https://cn-shanghai-alicloud-aimesh.api.clickzetta.com/gateway/v1 |
| Tencent Cloud Shanghai | https://ap-shanghai-tencentcloud-aimesh.api.clickzetta.com/gateway/v1 |
| AWS Singapore | https://ap-southeast-1-aws-aimesh.api.singdata.com/gateway/v1 |
Test the Connection
View and Switch LLMs
Usage Examples
Scenario: Bulk-create AI Gateway Keys for a Development Team
Scenario: Query Models from a Specific Provider
Scenario: Register an Agent LLM and Switch to It
Notes
| Note | Description |
|---|---|
| vApiKey security | key list returns a masked value; key get returns the full value. Do not write the full Key into logs or commit it to git |
| Key naming | Use alias to indicate purpose: dev_alice, prod_agent, staging_test |
| Quota takes effect immediately | Quota changes apply right away without restarting any service |
| model list output | When the output is large, use --format json and pipe for filtering |
| clickzetta provider | Requires both --api-key and --base-url; neither can be omitted. Alternatively, use --add-to-llm during upsert for automatic injection |
| provider options | agent llm add supports clickzetta / openai / openai-compatible / anthropic / bedrock / google / azure / openrouter |
Related Documentation
- AI Gateway Quick Start — Creating API Keys and routing policies in Studio
- AI Gateway Product Introduction — Endpoint management, quotas, monitoring
- AI Gateway in Practice: Calling LLMs with SQL — AI_COMPLETE text mode
- Analyzing Images in SQL — AI_COMPLETE image mode
- cz-cli Installation and Setup Guide — Setting up the cz-cli environment
