Connection basics

To call the ShangHai Do API, use the site URL, your site API key, and the exact model name.

If you want to configure an editor or command line tool, please select the corresponding tutorial from Client Tool Access Overview, including Cursor, VS Code, WorkBuddy, TRAE, JetBrains and various command line tools.

From registration to your first request

  1. First create an account and follow the registration prompts; if you already have an account, sign in.
  2. Open API Keys in the console, click Create API Key, enter a name, set the expiration and quota, and save your changes. Copy the full key from the list; a masked value containing asterisks cannot authenticate requests.
  3. Check that your account has enough balance in Wallet & Billing. Unlimited quota removes the separate quota limit for that key; requests still consume your account balance.
  4. Query the models visible to your key using the example below, then select a chat model for your first request. If qwen3.8-flash is absent, replace the example model name with a chat model you can access.
  5. After receiving HTTP 200 and a text reply in choices[0].message.content, open Usage Logs and check usage and charges by request time, model name, and API key.

Address and Credentials

Purpose Fill in content
Site root address https://shanghaido.com
Most OpenAI compatible clients Base URL https://shanghaido.com/v1
Claude Code of ANTHROPIC_BASE_URL https://shanghaido.com
Authentication request header Authorization: Bearer YOUR_API_KEY
Query the visible model of the current token GET /v1/models

YOUR_API_KEY is a placeholder. Please create and copy the API Key (access key) on the "API Keys" page of the ShangHai Do console, and then replace it. If you use other ShangHai Do deployment, please replace the domain name. The Base URL of most clients is filled in /v1; VS Code custom interface, TRAE full URL mode, CodeBuddy CLI, etc. require the complete request path, please refer to the corresponding tutorial.

Query available models first

Linux, macOS, or Git Bash:

export SHANHAI_BASE_URL="https://shanghaido.com"
export SHANHAI_API_KEY="YOUR_API_KEY"
curl "$SHANHAI_BASE_URL/v1/models" \
  -H "Authorization: Bearer $SHANHAI_API_KEY"

Windows PowerShell:

$env:SHANHAI_BASE_URL = "https://shanghaido.com"
$env:SHANHAI_API_KEY = "YOUR_API_KEY"
$models = Invoke-RestMethod `
  -Uri "$env:SHANHAI_BASE_URL/v1/models" `
  -Headers @{ Authorization = "Bearer $env:SHANHAI_API_KEY" }
$models.data | Select-Object id

Read the exact model name from data[].id. The public models and pricing page lists prices and billing units; this query determines which models your key can see. A listed model does not necessarily support every endpoint or parameter.

First call

First replace the following address and token with the site address and site token you used when visiting this site. SHANHAI_BASE_URL fill in the root address of the website in the browser address bar, excluding /docs, /v1 or other interface paths. The examples in this article use Bash (Linux, macOS, or Git Bash).

export SHANHAI_BASE_URL="https://shanghaido.com"
export SHANHAI_API_KEY="YOUR_API_KEY"
curl "$SHANHAI_BASE_URL/v1/chat/completions" \
  -H "Authorization: Bearer $SHANHAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.8-flash",
    "messages": [{"role": "user", "content": "请回复:连接成功"}],
    "max_tokens": 512,
    "stream": false
  }'

Windows PowerShell can be used:

$env:SHANHAI_BASE_URL = "https://shanghaido.com"
$env:SHANHAI_API_KEY = "YOUR_API_KEY"
$body = @{
  model = "qwen3.8-flash"
  messages = @(@{ role = "user"; content = "请回复:连接成功" })
  max_tokens = 512
  stream = $false
} | ConvertTo-Json -Depth 5
$result = Invoke-RestMethod `
  -Uri "$env:SHANHAI_BASE_URL/v1/chat/completions" `
  -Method Post `
  -Headers @{ Authorization = "Bearer $env:SHANHAI_API_KEY" } `
  -ContentType "application/json; charset=utf-8" `
  -Body ([System.Text.Encoding]::UTF8.GetBytes($body))
$result.choices[0].message.content

Read choices[0].message.content. Start with a chat model visible to your key and keep stream: false. After obtaining a text reply, follow the relevant guide to configure your client or use other capabilities.

Select interface

Capability Interface Description
Chat POST /v1/chat/completions Send message and get text replies
Picture generation POST /v1/images/generations Text generation picture; other pictures use /v1/images/edits
Video submission POST /v1/videos Create video task and then query the status
Voice generation POST /v1/audio/speech Return audio file; includes text-to-speech and sound description generation
Video query GET /v1/videos/{task_id} Query video task status
Get video content GET /v1/videos/{task_id}/content Get video content after completion

Ordinary tokens do not need to fill in additional classification parameters. The actual visible model of the current token is subject to the result returned by GET /v1/models.

Common status codes

Status code Processing method
400 Check the model name, parameter type and parameter value
401 Check whether the token is valid and whether the Bearer request header is sent correctly
403 Check token permissions or account restrictions
404 Check whether the interface path is repeatedly spliced, or whether a non-existent task is accessed
429 Retry later according to the return prompt to reduce concurrency
503 Record the model name, time and request number, contact the site customer service to check the service status

Continue reading: Client tool access overview, Conversation interface, Picture interface, Video interface, Voice interface.

encountered a problem

If you encounter problems with calling or configuration, please contact the site customer service and provide the model name, error time and error information to facilitate troubleshooting.