BASE URL
https://devseek.space/v1
文档 · v2
devseek 使用 OpenAI Chat Completions 协议。只要改 base URL,任何 OpenAI SDK 都能工作。
BASE URL
https://devseek.space/v1
认证
Authorization: Bearer dsk-…
模型
deepseek-v4.1-flash-free
224K tokens · 64K 令牌
curl https://devseek.space/v1/chat/completions \
-H "Authorization: Bearer $DEVSEEK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4.1-flash-free",
"stream": true,
"messages": [{"role": "user", "content": "Write a binary search in Rust"}]
}'import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["DEVSEEK_API_KEY"],
base_url="https://devseek.space/v1",
)
stream = client.chat.completions.create(
model="deepseek-v4.1-flash-free",
messages=[{"role": "user", "content": "Write a binary search in Rust"}],
max_tokens=4096,
stream=True,
)
for chunk in stream:
if chunk.choices:
print(chunk.choices[0].delta.content or "", end="")import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.DEVSEEK_API_KEY,
baseURL: "https://devseek.space/v1",
});
const stream = await client.chat.completions.create({
model: "deepseek-v4.1-flash-free",
messages: [{ role: "user", content: "Review this diff for bugs" }],
stream: true,
});
for await (const c of stream) process.stdout.write(c.choices[0]?.delta?.content ?? "");from openai import OpenAI
client = OpenAI(api_key=KEY, base_url="https://devseek.space/v1")
tools = [{"type": "function", "function": {
"name": "run_tests",
"description": "Run the test suite and return failures",
"parameters": {"type": "object",
"properties": {"path": {"type": "string"}},
"required": ["path"]}}}]
r = client.chat.completions.create(
model="deepseek-v4.1-flash-free", tools=tools,
messages=[{"role": "user", "content": "Tests in src/ fail. Investigate."}])
print(r.choices[0].message.tool_calls)# opencode.json — add devseek as an OpenAI-compatible provider
{
"provider": {
"devseek": {
"npm": "@ai-sdk/openai-compatible",
"options": { "baseURL": "https://devseek.space/v1", "apiKey": "{env:DEVSEEK_API_KEY}" },
"models": { "deepseek-v4.1-flash-free": { "limit": { "context": 224000, "output": 65536 } } }
}
}
}
# aider
export OPENAI_API_BASE=https://devseek.space/v1 OPENAI_API_KEY=$DEVSEEK_API_KEY
aider --model openai/deepseek-v4.1-flash-free
| 路由 | 作用 | 说明 |
|---|---|---|
GET /v1/models | 列出模型 | 需要密钥 |
POST /v1/chat/completions | 对话,可选流式,支持工具 | stream: true 使用 SSE;最后一个块携带用量 |
GET /api/status | 公开状态 JSON | 无需密钥 |
GET /health | 存活检查 | 无需密钥 |
输入上限为 224K 令牌,输出上限为 64K 令牌。我们在调用模型前按请求字节数估算输入大小(约每 token 3.3 字节),因此接近上限的请求可能会提前一点被拒绝。
会话是指已经开始但尚未结束的一次聊天补全请求。你的等级决定可以同时运行多少个会话:
超出上限时你会收到:
HTTP/1.1 429 Too Many Requests
Retry-After: 1
{"error":{"message":"Level 1 allows 3 concurrent sessions; 3 are already running. …",
"type":"rate_limit_error","code":"session_limit_reached",
"level":1,"session_limit":3,"sessions_in_use":3}}
任何接受 OpenAI 兼容提供方的工具都可以用。使用下面的 base URL、你的密钥和模型 ID。并行工具工作进程请保持在你会话上限以内。
| 状态 / 代码 | 含义 | 该怎么做 |
|---|---|---|
401 missing_api_key / invalid_api_key | 密钥缺失或错误 | 发送 Authorization: Bearer dsk-… |
400 invalid_json / invalid_messages | 请求体或 messages 格式错误 | 修正请求;不要原样重试 |
400 context_length_exceeded | 输入超过 224K 令牌 | 缩短或摘要对话 |
404 model_not_found | 未知模型 | 使用 deepseek-v4.1-flash-free |
413 body_too_large | 请求体超过 4 MB | 少发一些上下文 |
429 session_limit_reached | 并发会话过多 | 等待某个请求完成后再重试 |
503 upstream_saturated / upstream_busy | devseek 或模型已达容量上限 | 按 Retry-After 头等待后重试 |
502 upstream_error | 模型后端失败 | 可以安全重试 |