d
deepseek-ai/DeepSeek-V3.1-Base
模型介绍模型推理文件和版本分析
deepseek-ai/DeepSeek-V3.1 在线推理
文本生成
New
输入内容与模型对话
调用 API 代码
API 文档
cURL
添加令牌为:
import os import requests import json API_URL = "/v1/chat/completions" headers = { "Authorization": f"Bearer {os.environ['ACCESS_TOKEN']}", } def query(payload): response = requests.post(API_URL, headers=headers, json=payload, stream=True) for line in response.iter_lines(): if not line.startswith(b"data:"): continue if line.strip() == b"data:[DONE]": return yield json.loads(line.decode("utf-8").lstrip("data:").rstrip("/n")) chunks = query({ "model": "deepseek-ai/DeepSeek-V3.1", "messages": [ { "role": "user", "content": "告诉我一个有关宇宙的有趣事实?" } ], "stream": True }) for chunk in chunks: print(chunk["choices"])