quick start
Create a key, query the model, and complete your first conversation request.
This article uses the terminal and cURL to complete the first OpenAI compatible conversation request. After success, you should be able to query the models available for the current key, receive model replies, and find the corresponding call records in the console.
Preparation before starting
- Log in to Console and check the available balance in your account.
- Open API Key, create an independent key for testing, and confirm the validity period, quota, and group restrictions.
- Check the protocols supported by the model in Models and Prices. This article requires a text model that supports Chat Completions.
- Prepare a terminal with cURL installed. The following commands work in a Bash environment on macOS, Linux, or Windows; PowerShell users can use Bash execution in WSL.
Execute the example in your own terminal. Do not send real keys to others, or write public code, web scripts, or screenshots.
Step 1: Set address and key
The API root address of this site is https://dunduntoken.com. When making a handwritten HTTP request, spell the complete interface path after the root address; this article does not use the SDK, so /v1 is not appended to the environment variable.
The following commands support Bash and zsh respectively. When entering the key, it will not be echoed, nor will the key be written as a terminal history command:
export DUNDUN_BASE_URL="https://dunduntoken.com"
printf 'API Key: '
read -rs DUNDUN_API_KEY
printf '\n'
export DUNDUN_API_KEY
Variables only take effect on the current terminal and its started processes. After opening another terminal or restarting the application, you need to reset it in the actual running environment.
Step 2: Query the models available for the current key
curl --fail-with-body "$DUNDUN_BASE_URL/v1/models" \
-H "Authorization: Bearer $DUNDUN_API_KEY"
Returns JSON on success, where data is a list of models. Only the field structure is shown below, MODEL_ID is a placeholder:
{
"object": "list",
"data": [
{
"id": "MODEL_ID",
"object": "model"
}
]
}
Copy one of the actual responses, data[].id, and go to the model page to confirm that the model supports Chat Completions. The model ID must be kept intact and cannot be replaced with a display name or your own abbreviation.
If data is empty, first check the group and model restrictions of the current key. Do not directly copy model names from other accounts or other platforms.
Step 3: Send the first conversation request
Replace MODEL_ID in the JSON below with the actual model ID queried in the previous step, and then execute the request:
curl --fail-with-body "$DUNDUN_BASE_URL/v1/chat/completions" \
-H "Authorization: Bearer $DUNDUN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"MODEL_ID","messages":[{"role":"user","content":"只回复 OK"}]}'
| Request item | Function |
|---|---|
Authorization |
Use this site’s API Key for authentication |
Content-Type: application/json |
Description The request body is JSON |
model |
Specifies the model ID for which this key is available |
messages |
Send user message; this time only contains a short text |
This time a non-streaming response is used, and the reply text is usually located at choices[0].message.content. The following is an excerpt used to identify the fields. The actual response may contain other fields, and the model is not guaranteed to return OK verbatim:
{
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "OK"
},
"finish_reason": "stop"
}
]
}
Step 4: Check call records
Open Call Record, search for requests based on the time just now, and check the model, status and usage. This access verification is completed only when the client receives a normal reply and can confirm the corresponding call on the console.
If the terminal times out, don’t resend immediately and continuously. First check whether the call record has been generated, and then click Request Tracking and Retry to determine the next step.
How to check when the request fails
| Symptoms | Priority checks | Next steps |
|---|---|---|
401 |
Whether the correct key has been set on the current terminal and whether the key is valid | Recheck the API Key to avoid misuse of console credentials |
404 |
Whether the final URL contains duplicate /v1 and whether the model supports this path |
Compare Interface Overview |
| Prompt model or channel is not available | Exact model ID, key grouping and model restrictions | Use the same key to re-query /v1/models |
| Prompt that the quota is insufficient or the request is limited | The available quota and limit information of the account and key | Check the corresponding settings in the console |
| Connection failed or timed out | DNS, proxy, network and whether there are any request records | Read Network Troubleshooting |
cURL’s --fail-with-body preserves the response body on HTTP errors. Check both the status code and error content when troubleshooting; remove keys and sensitive information before submitting to support. For more information, see Error Codes and Troubleshooting.
Next step
- Integrate using code: Python with Node.js SDK.
- Use ready-made software: Client and Tool Integration.
- Use other protocols: Responses, Anthropic Messages, Gemini native protocol.
- Added capabilities for formal applications: Streaming output, Tool call.