API Reference
Overview
- Base URL:
https://open.dieyuyun.com - Authentication: Bearer Token or
x-api-keyheader (get your API Key from the console) - Protocol: HTTPS
Chat Completions
Text generation endpoint with multi-turn conversation and streaming support.
Request
POST /v1/chat/completionsParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model code, e.g. deepseek-v4-flash |
| messages | array | Yes | Message list |
| messages.role | string | Yes | Role: system, user, assistant |
| messages.content | string | Yes | Message content |
| temperature | number | No | Temperature, 0-2, default 1 |
| max_tokens | integer | No | Max tokens to generate |
| top_p | number | No | Top-p sampling, 0-1, default 1 |
| stream | boolean | No | Enable streaming, default false |
Request Example
{
"model": "deepseek-v4-flash",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "Hello!" }
],
"temperature": 0.7,
"max_tokens": 1024
}Response
{
"id": "chatcmpl-xxx",
"object": "chat.completion",
"created": 1700000000,
"model": "deepseek-v4-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 10,
"total_tokens": 30
}
}Streaming
Set stream: true to receive Server-Sent Events:
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","choices":[{"delta":{"content":"Hello"},"finish_reason":null}]}
data: {"id":"chatcmpl-xxx","object":"chat.completion.chunk","choices":[{"delta":{"content":"!"},"finish_reason":null}]}
data: [DONE]The last chunk in a streaming response includes a usage field for token statistics.
Messages (Anthropic Compatible)
Anthropic Messages API compatible endpoint for text generation. Use the Anthropic SDK to call directly.
Request
POST /v1/messagesAuthentication
Two methods are supported:
x-api-key: <your-api-key>(recommended, default for Anthropic SDK)Authorization: Bearer <your-api-key>
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model code, e.g. deepseek-v4-flash |
| messages | array | Yes | Message list |
| messages.role | string | Yes | Role: user, assistant |
| messages.content | string/array | Yes | Message content, supports string or content blocks |
| system | string/array | No | System prompt, supports string or content blocks |
| max_tokens | integer | Yes | Max tokens to generate |
| temperature | number | No | Temperature, 0-1, default 1 |
| top_p | number | No | Top-p sampling, 0-1, default 1 |
| stream | boolean | No | Enable streaming, default false |
| stop_sequences | array | No | List of stop sequences |
Request Example
{
"model": "deepseek-v4-flash",
"max_tokens": 1024,
"system": "You are a helpful assistant.",
"messages": [{ "role": "user", "content": "Hello!" }]
}Using the Anthropic Python SDK:
import anthropic
client = anthropic.Anthropic(
base_url="https://open.dieyuyun.com",
api_key="your-api-key"
)
message = client.messages.create(
model="deepseek-v4-flash",
max_tokens=1024,
messages=[
{"role": "user", "content": "Hello!"}
]
)
print(message.content[0].text)Response
{
"id": "msg_xxx",
"type": "message",
"role": "assistant",
"model": "deepseek-v4-flash",
"stop_reason": "end_turn",
"stop_sequence": null,
"content": [
{
"type": "text",
"text": "Hello! How can I help you today?"
}
],
"usage": {
"input_tokens": 10,
"output_tokens": 10
}
}Streaming
Set stream: true to receive Server-Sent Events. The event sequence is:
event: message_start
data: {"type":"message_start","message":{"id":"msg_xxx","type":"message","role":"assistant","model":"deepseek-v4-flash","stop_reason":null,"usage":{"input_tokens":10,"output_tokens":0}}}
event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Hello"}}
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"!"}}
event: content_block_stop
data: {"type":"content_block_stop","index":0}
event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"end_turn"},"usage":{"output_tokens":10}}
event: message_stop
data: {"type":"message_stop"}finish_reason Mapping
| Anthropic stop_reason | OpenAI finish_reason | Description |
|---|---|---|
| end_turn | stop | Normal stop |
| max_tokens | length | Max tokens hit |
Search Completions
Web search endpoint that generates answers based on real-time search results.
Request
POST /v1/search/completionsParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Model code that supports search |
| messages | array | Yes | Message list, same as Chat Completions |
| stream | boolean | No | Enable streaming, default false |
Request Example
{
"model": "deepseek-v4-flash",
"messages": [{ "role": "user", "content": "What are today's tech news?" }]
}Response
The response format is the same as Chat Completions, with search source citations included in the answer.
Images Generations
Generate images from text descriptions.
Request
POST /v1/images/generationsParameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Image generation model code |
| prompt | string | Yes | Text description of the image |
| n | integer | No | Number of images to generate, default 1 |
| size | string | No | Image size, e.g. 1024x1024 |
| response_format | string | No | Response format: url (default) or b64_json |
Request Example
{
"model": "gpt-image-2",
"prompt": "A white cat sitting on a windowsill",
"n": 1,
"size": "1024x1024"
}Response
{
"created": 1700000000,
"data": [
{
"url": "https://cdn.wuliang.ai/images/xxx.png"
}
]
}Balance
Queries the available balance of the tenant that owns the current API Key, along with that Key's daily/monthly budget usage. Useful for "usage query" features in third-party tools like CC Switch.
Request
GET /v1/balance HTTP/1.1
Host: open.dieyuyun.com
Authorization: Bearer sk-xxxxxxxxxxxxxxxxNo query parameters, no request body.
Response
{
"object": "balance",
"currency": "CNY",
"balance": 138.5,
"api_key": {
"id": "1923456789012345678",
"name": "claude-code",
"daily_budget": 20.0,
"daily_used": 3.25,
"daily_remaining": 16.75,
"daily_reset_at": "2026-06-09T00:00:00+08:00",
"monthly_budget": null,
"monthly_used": null,
"monthly_remaining": null,
"monthly_reset_at": null
}
}| Field | Description |
|---|---|
currency | Fixed CNY. |
balance | Total available (yuan) = top-up balance + gift balance. |
api_key.id / api_key.name | ID and name of the current API Key. |
api_key.daily_budget | Per-Key daily budget (yuan), null if not set. |
api_key.daily_used / daily_remaining | Consumed / remaining today (yuan). |
api_key.daily_reset_at | Next daily budget reset time (ISO8601). |
api_key.monthly_* | Monthly equivalents of the fields above. |
See Connect CC Switch for full third-party tool configuration examples.
Error Codes
| HTTP Status | Code | Description |
|---|---|---|
| 400 | INVALID_PARAMS | Invalid request parameters |
| 401 | UNAUTHORIZED | Invalid or expired API Key |
| 403 | FORBIDDEN | Access denied |
| 404 | MODEL_NOT_FOUND | Model not found or offline |
| 429 | RATE_LIMIT | Rate limit exceeded |
| 500 | INTERNAL_ERROR | Internal server error |
| 502 | UPSTREAM_ERROR | Upstream model service error |
| 504 | GATEWAY_TIMEOUT | Request timeout |
All error responses use JSON format:
{
"error": {
"code": "RATE_LIMIT",
"message": "Rate limit exceeded. Please retry after 60s.",
"request_id": "req-xxx"
}
}Use request_id to trace issues in the console request logs.
Rate Limits
- Default RPM (Requests Per Minute): 60
- Default TPM (Tokens Per Minute): 100,000
- Configurable per API Key in the console
When rate limited, a 429 status is returned with these response headers:
X-RateLimit-Limit: Total limit for the current windowX-RateLimit-Remaining: Remaining requests in the current windowRetry-After: Suggested retry wait time in seconds