When your AI applications serve global users, cross-border access to Alibaba Cloud Model Studio can introduce significant latency and instability. Edge Security Acceleration (ESA) reduces network latency and improves API request success rates through its global acceleration network. This guide shows you how to configure ESA to accelerate your Token Plan or Model Studio API endpoints.
Before you begin
You will need:
-
Prepare the domain you want to integrate with ESA.
-
An active Token Plan subscription or Model Studio account.
-
ESA Basic plan or higher.
NoteFor Chinese mainland deployments, your domain requires active ICP filing.
How it works
ESA accelerates your API requests through three layers:
User → ESA Edge Node → Smart Routing → Origin (Model Studio API)
↓ ↓ ↓ ↓
Global Reduces Optimal Your API
Users Latency Path Endpoint
Benefits:
-
30-50% latency reduction for global users.
-
Higher success rates through intelligent routing around network issues.
-
Simplified configuration - just replace your base URL.
Step 1: Get your Token Plan API domain
Your API domain depends on your service and protocol.
If you already have Token Plan
Find your API domain in the Token Plan console:
-
Open the Token Plan console.
-
Choose API Key Management.
-
Copy your Base URL - this is your API domain.
Your domain will be one of these:
OpenAI-compatible API
: https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1
Anthropic-compatible API
: https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic
Step 2: Configure ESA acceleration
Add your domain to ESA
-
In the ESA console, go to Websites and click Add Website.
-
In the wizard, configure the following settings :
-
Accelerated Region: Choose Global (recommended for worldwide users).
-
Plan: Choose Basic or higher.
-
-
Complete the payment.
ESA creates your site and displays it in the site list. This typically takes 1-2 minutes.
Configure a DNS record for API acceleration
Configure the DNS record with the following settings:
-
In the ESA console, select your site.
-
Go to and click Add Record.
-
Configure the record:
-
Record Type: Select CNAME.
-
Hostname: Enter a prefix for a custom subdomain, such as
ali-token-bj. -
Proxy Status: Turn on the switch to enable proxy acceleration.
-
Record Value: Select Domain Name.
-
Domain Name: Enter
token-plan.ap-southeast-1.maas.aliyuncs.com. -
Origin Host: Set to Match Origin's Domain Name.
-
After saving, the console displays your acceleration domain.
For example, api.example.com.
ESA automatically recognizes CNAME origins as domains. For A/AAAA records, enter IP addresses directly.
Configure origin fetch settings
Configure how ESA connects to your origin (separate from DNS configuration).
-
In the ESA console, select Websites, and then click the target site in the Website column.
-
In the navigation pane on the left, choose .
-
Configure the rule with these settings:
-
Rule Name: Enter a custom name, such as
TokenPlan. -
If requests match...: Set the condition to
Hostname equalsand enter the domain name that uses theali-token-bjprefix. -
Origin Protocol and Port: Set Origin Protocol to HTTPS and HTTPS Port to
443.
-
After the rule is saved, it appears in the Origin Rules list with status Active.
Enable smart routing (recommended)
Smart routing automatically selects the fastest path to your origin, improving success rates:
-
In the ESA console, select Websites, and then click the target site in the Website column.
-
In the left navigation pane, choose .
-
Configure the rule:
-
Rule Name: Enter a custom name, such as
smart-routing. -
If requests match...: Set the condition to
Hostname equalsand enter the domain name that uses theali-token-bjprefix. -
Smart Routing: Turn on the switch.
-
After the rule is saved, it appears in the Network Optimization list with status Active.
DNS changes take 5-10 minutes to propagate. Verify with dig api.example.com or nslookup api.example.com.
Step 3: Test before production (recommended)
Before updating your application, verify ESA acceleration:
# Test your accelerated domain
curl -I http://ali-dashscope.example.com/v1/models
Expected output:
HTTP/2 200
x-ali-esa-id: 2c8f7b9a-1234-5678-abcd-ef0123456789
content-type: application/json
...
The x-ali-esa-id header confirms that ESA is processing the request.
Compare latency (optional):
# Direct access to origin
time curl -s https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/models > /dev/null
# Access through ESA
time curl -s http://ali-dashscope.example.com/v1/models > /dev/null
You should see reduced latency through ESA, especially from international locations.
Step 4: Update your AI application
Replace your API base URL. The key change:
Before: https://token-plan.ap-southeast-1.maas.aliyuncs.com
After: http://ali-dashscope.example.com
You can apply for a free edge certificate to enable HTTPS access.
OpenClaw configuration
Configure OpenClaw to use your accelerated domain.
Update the baseUrl field:
{
"models": {
"mode": "merge",
"providers": {
"bailian": {
# Replace the baseUrl field with your custom domain name.
"baseUrl": "http://ali-dashscope.example.com/v1",
"apiKey": "YOUR_API_KEY",
"api": "openai-completions",
"models":[
# Your custom model information
]
}
}
}
# Other configurations
}
Claude Code
macOS/Linux
File location: ~/.claude/settings.json
If the .claude directory doesn't exist, create it:
mkdir -p ~/.claude
Edit the configuration file:
nano ~/.claude/settings.json
Add this configuration:
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "{{YOUR_API_KEY}}",
# Replace the baseUrl field with your custom domain name.
"ANTHROPIC_BASE_URL": "http://ali-dashscope.example.com/apps/anthropic",
"ANTHROPIC_MODEL": "{{MODEL}}"
}
}
Save the file and restart your terminal.
Windows
File location: C:\Users\\.claude\settings.json
Using Command Prompt:
# Create the directory
if not exist "%USERPROFILE%\.claude" mkdir "%USERPROFILE%\.claude"
# Open the file in Notepad
notepad "%USERPROFILE%\.claude\settings.json"
Using PowerShell:
# Create the directory
mkdir -Force $HOME\.claude
# Open the file in Notepad
notepad $HOME\.claude\settings.json
Add this configuration:
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "{{YOUR_API_KEY}}",
# Replace the baseUrl field with your custom domain name.
"ANTHROPIC_BASE_URL": "http://ali-dashscope.example.com/apps/anthropic",
"ANTHROPIC_MODEL": "{{MODEL}}"
}
}
Save the file and restart your terminal.
Verify the configuration
After updating your application, verify ESA acceleration:
-
Run your application and make an API request.
-
Check the response headers for the
x-ali-esa-idheader. -
Monitor latency in your application logs.
You should see:
-
Response headers include
x-ali-esa-id(confirms ESA is processing requests). -
Reduced response times compared to direct origin access.
Troubleshooting
Connection refused or timeout errors
Cause: DNS records not propagated yet.
Solution: Wait 5-10 minutes and try again. Verify propagation with nslookup api.example.com.
HTTP 502 Bad Gateway
Cause: ESA cannot reach your origin.
Solution:
-
Verify your origin address is correct in the ESA console.
-
Confirm origin port is set to HTTPS 443 in your origin rule.
-
Check that your origin is accessible from the internet.
Certificate errors in applications
Cause: Your application requires HTTPS but the acceleration domain uses HTTP.
Solution: Apply for a free edge certificate in the ESA console. Choose SSL/TLS, then Edge Certificates.
Next steps
-
Monitor performance: Track latency and success rates in the ESA analytics dashboard.
-
Enable security features: Configure WAF rules and DDoS protection in the ESA console.