Quick start
A single chat-completions endpoint uses the same path as OpenAI. To connect, create an API Key in the console, set your Base URL to https://api.9start.cn/v1, and set the model to deepseek-flash。
Endpoint
https://api.9start.cn/v1
Your first request
Replace YOUR_API_KEY with the key created in the console. Keep it server-side. The public endpoint GET /v1/models lists available models without authentication.
The response follows the OpenAI structure: the response text is in choices[0].message.content, and usage is in usage , split into input, cached-input and output tokens, matching console usage records.
Get an API Key
Your API Key authenticates API requests.Open the consoleand follow these four steps.
- 1Sign in to the console with your service card code. The card code is the account; no separate registration is needed.
- 2Open API Keys, create a key and give it a descriptive name.
- 3The full key is shown only once. Save it immediately in server-side environment variables or a secret manager.
- 4Disable or delete unused keys in the list; the change takes effect immediately.
Never embed a key in frontend pages or client packages. Forward requests through your own backend and keep the key there.
Request parameters
Common fields are listed below. Other standard OpenAI request fields are forwarded unchanged; behavior depends on the model.
| Parameter | Type | Required | Description |
|---|---|---|---|
| messages | array | Yes | Conversation messages. Use system, user or assistant roles; include conversation history in chronological order. |
| model | string | Yes | Model ID. Currently only deepseek-flash is supported; other values return 400 model_not_supported. |
| stream | boolean | No | Defaults to false. Set true to stream incremental results over SSE. |
| temperature | number | No | Sampling temperature, from 0 to 2. Lower is more deterministic; higher is more varied. Omit to use the model default. |
| max_tokens | integer | No | Maximum output length for this generation, to help limit per-request cost. |
| tools | array | No | Tool (function) definitions, used with tool_choice for function calls and multi-turn tool workflows. |
| tool_choice | string | object | No | Tool selection: auto lets the model choose, none disables tools, or specify a function. |
| response_format | object | No | Response format for structured output such as JSON, suitable for programmatic parsing. |
| enable_thinking | boolean | No | Reasoning-mode switch. When enabled, reasoning precedes the answer; latency increases for more deliberate responses. |
Streaming
Set stream to true. The server streams SSE chunks; each frame contains delta only an incremental piece of text.
- Read and forward each chunk immediately. Buffering the full response in a proxy increases time to first token.
- Treat data: [DONE] as the end marker; do not rely on connection closure.
- Enable HTTP keep-alive. Use a client timeout of at least 60 seconds, or 180 seconds or more for long outputs and reasoning.
- Usage is supplied in the final frame or a separate usage frame for reconciliation.
Compatible features
Streaming
SSE delivers incremental output, so chat interfaces can display text as it is generated.
Tool calling
Standard tools structure for function calls and multi-turn workflows.
Structured output
Use response_format for JSON output that can be parsed and stored directly.
Reasoning mode
Use enable_thinking when a task benefits from additional reasoning.
Multi-turn conversations
Maintain conversation history with the standard messages structure.
Long context
Send long documents and codebases together to reduce information loss from splitting context.
Errors
Errors use the format {"error": {"code": "...", "message": "Description in Chinese"}}; the message can be displayed to users.
| Status | code | Meaning and action |
|---|---|---|
| 401 | invalid_api_key | The key is missing, disabled, or belongs to a banned account. Check the complete key and its console status. |
| 402 | insufficient_quota | Insufficient account balance. Service resumes when funds are added; no code changes are needed. |
| 429 | rate_limit_exceeded | Rate limit or pool-window capacity reached. Retry later with exponential backoff and lower concurrency. |
| 400 | invalid_request | Invalid request body. Check required fields, types and permitted ranges. |
| 400 | model_not_supported | Unsupported model. Use deepseek-flash. |
| 404 | not_found | Unknown path. Check for a missing /v1 prefix. |
| 500 | internal_error | Internal error. Retry once; if it persists, contact support with the request-id. |
| 501 | not_implemented | Feature not available, such as Anthropic-compatible /v1/messages. |
Limits and billing
- Input, cached-input and output tokens are billed separately. Weekdays 09:00–12:00 and 14:00–18:00 are peak periods at twice the off-peak rate.
- For prices and examples, seePricing。
- Limits apply per API Key: five-hour allowance, daily allowance and requests per second (QPS). Reaching any limit returns 429.
- Contact support for higher allowances or concurrency; you can keep your key.
- Console usage is grouped by day and can be exported as CSV for reconciliation.
FAQ
Use an OpenAI-compatible SDK, including the official Python and Node.js SDKs. Set base_url to the Base URL above and the model to deepseek-flash.
Use at least 60 seconds, or 180 seconds or more for long outputs and reasoning. Enable keep-alive and consume streams incrementally.
Concurrency and QPS are limited per API Key. Contact support if you need higher limits.
Actual input, cached-input and output tokens are billed separately; peak rates are twice off-peak rates. Review daily usage and export CSV in the console.
Keep keys in server-side environment variables, never frontend pages, client packages or public repositories. If leaked, disable the key, then delete and replace it.
Only a digest is stored for security, so the key cannot be shown again. Delete it and create a replacement, then save the new key.
402 means insufficient balance; service resumes after funding. 429 means a rate or pool limit; retry later with exponential backoff.