Before you start: endpoints and protocols
This guide calls DeepSeek through DAYWORLD, using the JD Cloud Flash model deepseek-flash in examples. Create a DAYWORLD API key, then confirm the models and protocols permitted for that key.
| Purpose | Address | Configuration |
|---|---|---|
| OpenAI SDK Base URL | https://api.example.com/v1 | For Chat Completions and Responses; the SDK appends the resource path. |
| Chat Completions | POST /v1/chat/completions | model + messages |
| Responses | POST /v1/responses | model + input |
| Anthropic SDK Base URL | https://api.example.com | The SDK appends /v1/messages. Do not append /anthropic on DAYWORLD. |
| Available models | GET /v1/models | Authenticate with the intended key and read data[].id. |
API endpoints, routes and available log fields are confirmed when a service is provisioned. An entry route does not determine inference or all storage locations.
Prepare your key and environment
- Confirm the assigned API endpoint, model IDs and supported protocols when the service is provisioned. api.example.com is a placeholder.
- Protect the provisioned key and confirm its model scope, expiry and quota. Organization members use their own authorized scope.
- Set the variables below in a local terminal and replace the example endpoint and key with your assigned information.
export DAYWORLD_API_KEY="YOUR_DAYWORLD_API_KEY"
export DAYWORLD_BASE_URL="https://api.example.com/v1"
export DAYWORLD_MODEL="deepseek-flash"$env:DAYWORLD_API_KEY = "YOUR_DAYWORLD_API_KEY"
$env:DAYWORLD_BASE_URL = "https://api.example.com/v1"
$env:DAYWORLD_MODEL = "deepseek-flash"Replace YOUR_DAYWORLD_API_KEY locally. OpenAI-format requests use Authorization: Bearer. Messages also accepts x-api-key; send anthropic-version: 2023-06-01.
Model names and permissions
JD Cloud provides computing support with a high service level. Actual availability remains subject to current model supply and your service terms. Query the model IDs available to your key first:
curl --fail-with-body --silent --show-error \
"$DAYWORLD_BASE_URL/models" \
-H "Authorization: Bearer $DAYWORLD_API_KEY"| Request model | Description |
|---|---|
deepseek-flash | JD Cloud Flash for personal accounts and enterprise identities using this name. The default in this guide. |
DeepSeek-V4.1-Flash-1017-b-jd | The JD Cloud Flash name used by some enterprise catalogs. Use it when returned by your catalog. |
deepseek-v4.1-flash-cyber-fq | FrontierQuest DeepSeek Flash cybersecurity edition. Requires its own key permission; consult your catalog for prices and protocols. |
The JD Flash aliases above are case-insensitive, but copy the catalog spelling for new integrations. The legacy deepseek-v4.1-flash alias resolves to JD Flash; it is not the cybersecurity model. An alias grants no additional permission and does not change your account prices.
A quote-only model with no active supply cannot be called. Seeing a price does not grant key access. GET /v1/models lists models available to that key, not every model on the platform.
Make your first request
Set the environment variables above first. This first request disables thinking and uses a small output limit to check authentication and model selection. Each actual model request is billed under your account rules.
Python: python -m pip install --upgrade openai. Node.js: npm install openai, save the sample as quickstart.mjs, then run node quickstart.mjs. In Windows PowerShell choose its own tab; Bash backslash continuation is not PowerShell syntax.
curl --fail-with-body --silent --show-error \
"$DAYWORLD_BASE_URL/chat/completions" \
-H "Authorization: Bearer $DAYWORLD_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<JSON
{
"model": "$DAYWORLD_MODEL",
"messages": [{"role": "user", "content": "Explain an API in one short sentence."}],
"thinking": {"type": "disabled"},
"max_tokens": 256,
"stream": false
}
JSON$body = @{
model = $env:DAYWORLD_MODEL
messages = @(@{role="user"; content="Explain an API in one short sentence."})
thinking = @{type="disabled"}
max_tokens = 256
stream = $false
} | ConvertTo-Json -Depth 8
$request = @{
Method = "Post"
Uri = "$env:DAYWORLD_BASE_URL/chat/completions"
Headers = @{Authorization="Bearer $env:DAYWORLD_API_KEY"}
ContentType = "application/json"
Body = $body
}
$result = Invoke-RestMethod @request
$result.choices[0].message.contentimport os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["DAYWORLD_API_KEY"],
base_url=os.environ["DAYWORLD_BASE_URL"],
timeout=90.0,
max_retries=0,
)
result = client.chat.completions.create(
model=os.environ["DAYWORLD_MODEL"],
messages=[{"role": "user", "content": "Explain an API in one short sentence."}],
max_tokens=256,
extra_body={"thinking": {"type": "disabled"}},
)
print(result.choices[0].message.content)
print(result.usage)import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.DAYWORLD_API_KEY,
baseURL: process.env.DAYWORLD_BASE_URL,
timeout: 90_000,
maxRetries: 0,
});
const result = await client.chat.completions.create({
model: process.env.DAYWORLD_MODEL,
messages: [{role: "user", content: "Explain an API in one short sentence."}],
thinking: {type: "disabled"},
max_tokens: 256,
});
console.log(result.choices[0].message.content);
console.log(result.usage);Request and response shapes
{
"model": "deepseek-flash",
"messages": [
{
"role": "user",
"content": "Reply with OK."
}
],
"thinking": {
"type": "disabled"
},
"max_tokens": 256,
"stream": false
}{
"id": "example_completion",
"object": "chat.completion",
"model": "deepseek-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "OK"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 1,
"total_tokens": 13
}
}Text is in choices[0].message.content. Check finish_reason: stop is normal completion, length indicates a budget or context cutoff, and tool_calls requires tool handling. HTTP 200 alone does not prove that an answer is complete.
Streaming with SSE
Set stream: true and consume choices[].delta.content incrementally instead of waiting for a complete JSON document. Use --no-buffer in cURL and disable response buffering in your reverse proxy.
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["DAYWORLD_API_KEY"],
base_url=os.environ["DAYWORLD_BASE_URL"],
timeout=90.0, max_retries=0)
with client.chat.completions.create(
model=os.environ["DAYWORLD_MODEL"],
messages=[{"role": "user", "content": "Give three short tips for writing readable code."}],
stream=True,
stream_options={"include_usage": True},
max_tokens=512,
extra_body={"thinking": {"type": "disabled"}},
) as stream:
for chunk in stream:
if chunk.usage is not None:
print("\nUsage:", chunk.usage)
if not chunk.choices:
continue
text = chunk.choices[0].delta.content
if text:
print(text, end="", flush=True)
print()curl --no-buffer --fail-with-body --silent --show-error \
"$DAYWORLD_BASE_URL/chat/completions" \
-H "Authorization: Bearer $DAYWORLD_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<JSON
{"model":"$DAYWORLD_MODEL","messages":[{"role":"user","content":"Reply with OK."}],"stream":true,"max_tokens":256,"thinking":{"type":"disabled"}}
JSON- Chat SSE uses
data:frames and normally ends withdata: [DONE]. TCP chunks are not event boundaries; parse SSE records separated by blank lines. - Handle empty
choices, usage-only chunks and deltas with no text. Usage can arrive in a terminal or separate chunk depending on the provider. - During reasoning,
delta.contentcan be empty whiledelta.reasoning_contentcarries reasoning text. - A disconnected stream does not prove the request was never processed. Do not blindly replay after receiving partial output; a replay is a separate call.
Thinking mode
DeepSeek controls thinking with thinking and selects effort with reasoning_effort. Pass extension fields through extra_body in the OpenAI Python SDK. Provider deployments can differ; these are current official parameter forms, not a claim that every historical model supports them.
| Protocol | Disable | Enable and effort |
|---|---|---|
| Chat Completions | thinking: {"type":"disabled"} | thinking: {"type":"enabled"}reasoning_effort: "low" | "high" | "max" |
| Responses | reasoning: {"effort":"none"} | reasoning: {"effort":"low" | "high" | "max"} |
| Messages | thinking: {"type":"disabled"} | thinking: {"type":"enabled"}output_config: {"effort":"low" | "high" | "max"} |
# Reuse the OpenAI client from the quickstart.
result = client.chat.completions.create(
model=os.environ["DAYWORLD_MODEL"],
messages=[{"role": "user", "content": "Check whether 23 times 17 equals 391."}],
reasoning_effort="high",
extra_body={"thinking": {"type": "enabled"}},
max_tokens=2048,
)
message = result.choices[0].message
print("Reasoning:", getattr(message, "reasoning_content", None))
print("Answer:", message.content)
print("Finish:", result.choices[0].finish_reason)Read reasoning and final text separately. Sampling parameters such as temperature may not take effect in thinking mode. Do not assume official defaults, maximum context or maximum output budgets apply unchanged to every DAYWORLD provider.
Multi-turn conversations
Chat Completions does not reconstruct history from a previous response ID. Send the required messages on each turn and append user → assistant → user in order. Bound history length and avoid accidentally appending a whole conversation twice.
# Reuse the OpenAI client from the quickstart.
history = [{"role": "user", "content": "Suggest a short name for a library."}]
first = client.chat.completions.create(
model=os.environ["DAYWORLD_MODEL"], messages=history,
max_tokens=256, extra_body={"thinking": {"type": "disabled"}},
)
history.append({"role": "assistant", "content": first.choices[0].message.content})
history.append({"role": "user", "content": "Explain why that name fits."})
second = client.chat.completions.create(
model=os.environ["DAYWORLD_MODEL"], messages=history,
max_tokens=256, extra_body={"thinking": {"type": "disabled"}},
)
print(second.choices[0].message.content)Complete a tool-call round trip
The model returns a function name and JSON arguments. Your application executes the function; DAYWORLD does not run your local code. The full loop is: declare tools → read tool_calls → validate and execute → return results with tool_call_id → request the final answer.
Complete Python example: query demo library opening hours
import json
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["DAYWORLD_API_KEY"],
base_url=os.environ["DAYWORLD_BASE_URL"],
timeout=90.0, max_retries=0)
tools = [{
"type": "function",
"function": {
"name": "lookup_opening_hours",
"description": "Read the demo library opening hours for a weekday.",
"parameters": {
"type": "object",
"properties": {"day": {"type": "string", "enum": ["monday", "tuesday"]}},
"required": ["day"],
"additionalProperties": False,
},
},
}]
messages = [{"role": "user", "content": "Use the opening-hours tool for monday."}]
demo_hours = {"monday": "09:00-18:00", "tuesday": "09:00-18:00"}
for _ in range(3):
result = client.chat.completions.create(
model=os.environ["DAYWORLD_MODEL"], messages=messages,
tools=tools, max_tokens=512,
extra_body={"thinking": {"type": "disabled"}},
)
message = result.choices[0].message
if not message.tool_calls:
print(message.content)
break
# Preserve the complete assistant message, including tool call IDs.
messages.append(message.model_dump(exclude_none=True))
for call in message.tool_calls:
if call.function.name != "lookup_opening_hours":
raise ValueError("Unexpected tool name")
args = json.loads(call.function.arguments)
if set(args) != {"day"} or args["day"] not in demo_hours:
raise ValueError("Invalid tool arguments")
output = {"day": args["day"], "hours": demo_hours[args["day"]]}
messages.append({"role": "tool", "tool_call_id": call.id,
"content": json.dumps(output)})
else:
raise RuntimeError("Tool round limit reached")This example reads fixed demo data and limits the loop to three rounds. Handle every tool call and match each result to its original call ID. Do not execute arbitrary model-generated code or pass argument strings to eval. Keep the complete assistant-message preservation when enabling thinking.
Streaming tool calls: assemble before parsing
# Collect all fragments before parsing or executing a tool call.
calls = {}
for chunk in stream:
if not chunk.choices:
continue
for part in chunk.choices[0].delta.tool_calls or []:
item = calls.setdefault(part.index, {"id": "", "name": "", "arguments": ""})
if part.id:
item["id"] = part.id
if part.function:
item["name"] += part.function.name or ""
item["arguments"] += part.function.arguments or ""
# Validate the completed arguments and tool name against your allowlist next.Streaming function.arguments contains string fragments, not a complete JSON object in every frame. Assemble by index, then parse and validate the completed call against your function allowlist.
JSON output
Request JSON with response_format: {"type":"json_object"} and explicitly mention JSON and the intended shape in the prompt. Check empty or truncated output before parsing, then validate application fields. Valid JSON is not the same as a valid business schema.
# Reuse the OpenAI client from the quickstart.
import json
result = client.chat.completions.create(
model=os.environ["DAYWORLD_MODEL"],
messages=[
{"role": "system", "content": 'Return JSON only, shaped like {"title":"...","tags":["..."]}.'},
{"role": "user", "content": "Summarize a guide about unit testing."},
],
response_format={"type": "json_object"},
max_tokens=512,
extra_body={"thinking": {"type": "disabled"}},
)
choice = result.choices[0]
if choice.finish_reason != "stop" or not (choice.message.content or "").strip():
raise ValueError("Incomplete or empty JSON response")
data = json.loads(choice.message.content)
if not isinstance(data, dict) or not isinstance(data.get("title"), str) or not isinstance(data.get("tags"), list):
raise ValueError("Unexpected application schema")
print(data)Responses protocol
The current JD Flash offering supports POST /v1/responses. Use input, max_output_tokens and reasoning.effort; changing only the URL of a Chat messages payload is insufficient.
# Reuse the OpenAI client from the quickstart.
result = client.responses.create(
model=os.environ["DAYWORLD_MODEL"],
input=[{"role": "user", "content": "Explain an API in one short sentence."}],
reasoning={"effort": "none"},
max_output_tokens=256,
store=False,
)
print(result.output_text){
"model": "deepseek-flash",
"input": [
{
"role": "user",
"content": "Reply with OK."
}
],
"reasoning": {
"effort": "none"
},
"max_output_tokens": 256,
"store": false,
"stream": false
}# Reuse the OpenAI client from the quickstart.
with client.responses.create(
model=os.environ["DAYWORLD_MODEL"], input="Give three short study tips.",
reasoning={"effort": "none"}, max_output_tokens=512,
store=False, stream=True,
) as stream:
for event in stream:
if event.type == "response.output_text.delta":
print(event.delta, end="", flush=True)
elif event.type in {"response.failed", "response.incomplete"}:
raise RuntimeError(f"Generation ended with {event.type}")
elif event.type == "response.completed":
print("\nUsage:", event.response.usage)Anthropic Messages protocol
This protocol still calls DeepSeek. The full HTTP endpoint is https://api.example.com/v1/messages; set the Anthropic SDK base URL to https://api.example.com. Both samples use the same DAYWORLD key and model ID.
Python SDK: python -m pip install --upgrade anthropic. Response content is a list of blocks. Streaming uses events such as message_start, content_block_delta and message_stop, not Chat’s choices structure.
curl --fail-with-body --silent --show-error \
"https://api.example.com/v1/messages" \
-H "x-api-key: $DAYWORLD_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
--data-binary @- <<JSON
{"model":"$DAYWORLD_MODEL","max_tokens":256,"thinking":{"type":"disabled"},"messages":[{"role":"user","content":"Reply with OK."}]}
JSONimport os
from anthropic import Anthropic
client = Anthropic(
api_key=os.environ["DAYWORLD_API_KEY"],
base_url="https://api.example.com",
timeout=90.0, max_retries=0,
)
result = client.messages.create(
model=os.environ["DAYWORLD_MODEL"],
max_tokens=256,
thinking={"type": "disabled"},
messages=[{"role": "user", "content": "Reply with OK."}],
)
print("".join(block.text for block in result.content if block.type == "text"))Usage, cache and prices
| Protocol | Common fields | Interpretation |
|---|---|---|
| Chat | usage.prompt_tokensusage.completion_tokensusage.total_tokens | Read final request usage; do not sum repeated cumulative values from stream chunks. |
| Chat cache | prompt_cache_hit_tokensprompt_cache_miss_tokens | When supplied, these split cached and uncached input; do not add them again to total input. |
| Responses | usage.input_tokensusage.output_tokens | Read the complete response or terminal event; cache and reasoning details depend on the actual response. |
| Messages | usage.input_tokensusage.output_tokens | Cache read/write fields can be separate; interpret them under the Messages usage convention. |
DeepSeek cache reuse is based on repeated input prefixes and is best-effort. Stable system instructions and unchanged context prefixes help reuse; output is still generated by the model rather than served as a fixed cached answer.
Actual CNY rates, permissions and billing rules follow the provisioned service’s price schedule and effective agreements. DeepSeek peak periods are 09:00–12:00 and 14:00–18:00 every day in Beijing time (UTC+8), with off-peak periods otherwise. This page publishes no fixed unit prices and this public website does not process billing.
Errors and retries
Keep the HTTP status, response body and X-Oneapi-Request-Id response header. For a stream, also retain its final observed event and partial result. Give support the time, route hostname, model ID and request ID while redacting full keys and sensitive input.
| Status | Check first | Action |
|---|---|---|
| 400 | JSON, required fields, protocol parameters and context length. | Correct the request; do not repeatedly retry it unchanged. |
| 401 | DAYWORLD key, authentication format, expiry and revocation. | Fix authentication; keep the key out of URLs. |
| 402 / 403 | The returned balance, whitelist, organization allocation or permission reason. | Resolve the stated cause; a different model spelling grants no access. |
| 404 | Endpoint path, duplicate /v1, model spelling and active supply. | Check the catalog and protocol before changing endpoints. |
| 429 | Returned message, rule, scope, limit, window_seconds and retry_after. | Honor Retry-After and reduce concurrency/RPM. A zero allocation requires assignment; waiting does not create quota. |
| 500 / 502 / 503 / 504 | Provider failure, unavailable channels, gateway errors or timeouts. | Use bounded backoff before output has arrived; after partial output, decide explicitly whether to make another call. |
Bound retries, use exponential backoff with jitter and honor Retry-After. SDKs can retry automatically; samples set max_retries=0 (Node.js: maxRetries: 0) so first-run debugging does not hide repeated calls. DeepSeek’s direct-service rate-limit policy does not replace DAYWORLD account or organization limits.
Quotas and feature boundaries
- Organization shared balance, personal balance, member spending caps and key quota are different limits. A member cap does not create another independent cash balance. Check the organization page and bill for the actual funding source.
- The three native protocols have different payloads and terminal SSE events. Current JD Flash is connected through Chat Completions, Responses and Messages. Use only catalog-confirmed protocols for the cybersecurity edition or historical models.
- Official Files, search, Vision, FIM and Beta strict features are not automatically enabled by protocol compatibility. This guide does not offer examples for features not individually confirmed on DAYWORLD.
- Do not invent -thinking or -high model suffixes. Use the parameters in this guide while retaining the model ID returned by your account catalog.
Request field reference
| Field | Type | Required | Notes |
|---|---|---|---|
model | string | Yes | A model ID from the current key catalog. |
messages | array | Yes | At least one message with role and applicable content; tool results also require tool_call_id. |
stream | boolean | No | Defaults to false; true returns SSE. |
max_tokens | integer | No | A positive integer. The effective limit depends on deployment, context and reasoning budget. |
thinking | object | No | type is enabled or disabled; use extra_body in the Python SDK. |
tools | array | No | Declares function tools; your application handles returned tool_calls. |
| Purpose | Chat Completions | Responses | Messages |
|---|---|---|---|
| Model | model | model | model |
| Input | messages | input | messages |
| System instruction | messages[]: role=system | instructions | system |
| Output limit | max_tokens | max_output_tokens | max_tokens |
| Streaming | stream | stream | stream |
| Function tools | tools[].function | tools[]: type=function | tools[].input_schema |
| Final text | choices[0].message.content | output[].content[] / SDK output_text | content[]: type=text |
Start with a minimal request, then add thinking, tools or output formats one at a time so compatibility problems remain easy to isolate. This guide currently covers DeepSeek only.
Official references and DAYWORLD rules
- DeepSeek: first API call
- Chat Completions API reference
- Thinking mode · Tool Calls · JSON Output
- Responses API · Anthropic API · Context cache
Official sources explain native protocols. DAYWORLD endpoints, model IDs, key permissions, active supply and CNY prices are determined by your current DAYWORLD catalog and bills. Documentation reviewed: 2026-11-10.