https://api.lkeap.tencentcloud.com/v1https://api.lkeap.tencentcloud.com/v1/chat/completions模型 | 参数量 | 最大上下文长度 | 最大输入长度 | 最大输出长度 |
DeepSeek-R1 | 671B | 48k | 16k | 32k |
DeepSeek-R1-0528 | 671B | 48k | 16k | 32k |
模型 | 参数量 | 最大上下文长度 | 最大输入长度 | 最大输出长度 |
DeepSeek-V3 | 671B | 48k | 16k | 32k |
模型 | 参数量 | 最大上下文长度 | 最大输入长度 | 最大输出长度 |
DeepSeek-V3.1-Terminus | 685B | 128k | 96k | 32k |
pip install -U openai
import osfrom openai import OpenAIclient = OpenAI(api_key="LKEAP_API_KEY",base_url="https://api.lkeap.tencentcloud.com/v1",)completion = client.chat.completions.create(model="deepseek-r1",messages=[{'role': 'user', 'content': 'Which is greater, 9.9 or 9.11?'}])print("reasoning_content:")print(completion.choices[0].message.reasoning_content)print("content:")print(completion.choices[0].message.content)
curl https://api.lkeap.tencentcloud.com/v1/chat/completions \\-H "Content-Type: application/json" \\-H "Authorization: Bearer sk-xxxxxxxxxxx" \\-d '{"model": "deepseek-r1","messages": [{"role": "user","content": "hello"}],"stream": false}'
import osfrom openai import OpenAIclient = OpenAI(api_key="LKEAP_API_KEY",base_url="https://api.lkeap.tencentcloud.com/v1",)messages = [{'role': 'user', 'content': 'hello'},{'role': 'assistant', 'content': 'hi, how can I assist you?'},{'role': 'user', 'content': 'Which is greater, 9.9 or 9.11?'}]completion = client.chat.completions.create(model="deepseek-r1",messages=messages)print("="*20+"first-round dialogue"+"="*20)print("="*20+"reasoning_content"+"="*20)print(completion.choices[0].message.reasoning_content)print("="*20+"content"+"="*20)print(completion.choices[0].message.content)messages.append({'role': 'assistant', 'content': completion.choices[0].message.content})messages.append({'role': 'user', 'content': 'who are you'})print("="*20+"second-round dialogue"+"="*20)completion = client.chat.completions.create(model="deepseek-r1",messages=messages)print("="*20+"reasoning_content"+"="*20)print(completion.choices[0].message.reasoning_content)print("="*20+"content"+"="*20)print(completion.choices[0].message.content)
curl https://api.lkeap.tencentcloud.com/v1/chat/completions \\-H "Content-Type: application/json" \\-H "Authorization: Bearer sk-xxxxxxxxxxx" \\-d '{"model": "deepseek-r1","messages": [{"role": "user","content": "hello"},{"role": "assistant","content": "hi, how can I assist you?"},{"role": "user","content": "Which is greater, 9.9 or 9.11?"}],"stream": true}'
from openai import OpenAIimport osclient = OpenAI(api_key="LKEAP_API_KEY",base_url="https://api.lkeap.tencentcloud.com/v1",)def main():reasoning_content = ""answer_content = ""is_answering = False# Create chat completion requeststream = client.chat.completions.create(model="deepseek-r1",messages=[{"role": "user", "content": "Which is greater, 9.9 or 9.11?"}],stream=True)print("\\n" + "=" * 20 + "reasoning processes" + "=" * 20 + "\\n")for chunk in stream:# Process Usage Informationif not getattr(chunk, 'choices', None):print("\\n" + "=" * 20 + "Token usage" + "=" * 20 + "\\n")print(chunk.usage)continuedelta = chunk.choices[0].deltaif not getattr(delta, 'reasoning_content', None) and not getattr(delta, 'content', None):continueif not getattr(delta, 'reasoning_content', None) and not is_answering:print("\\n" + "=" * 20 + "reasoning_content" + "=" * 20 + "\\n")is_answering = Trueif getattr(delta, 'reasoning_content', None):print(delta.reasoning_content, end='', flush=True)reasoning_content += delta.reasoning_contentelif getattr(delta, 'content', None):print(delta.content, end='', flush=True)answer_content += delta.contentif __name__ == "__main__":try:main()except Exception as e:print(f"error:{e}")
curl https://api.lkeap.tencentcloud.com/v1/chat/completions \\-H "Content-Type: application/json" \\-H "Authorization: Bearer sk-xxxxxxxxxxx" \\-d '{"model": "deepseek-r1","messages": [{"role": "user","content": "hello"}],"stream": true}'

第一次请求示例:```pythoncurl --location 'https://api.lkeap.tencentcloud.com/v1/chat/completions' \\-H "Content-Type: application/json" \\-H "Authorization: Bearer $API_KEY" \\--data '{"model": "deepseek-v3","messages": [{"role": "user","content": "What's the weather like in Paris today?"}],"tools": [{"type": "function","function": {"name": "get_weather","description": "Get current temperature for provided coordinates in celsius.","parameters": {"type": "object","properties": {"latitude": {"type": "number"},"longitude": {"type": "number"}},"required": ["latitude","longitude"]}}}]}'```第一次响应示例:JSON```json{"id": "cabe32d2b30dd30ac3d7aad02f235dd4","choices": [{"finish_reason": "tool_calls","index": 0,"message": {"content": "调用天气查询工具(get_weather)来获取巴黎的天气信息。\\n\\t\\n\\t用户想要知道今天巴黎的天气。我需要调用天气查询工具(get_weather)来获取巴黎的天气信息。","role": "assistant","tool_calls": [{"id": "call_cvdrgkk2c3mceb26d7sg","function": {"arguments": "{\\"latitude\\":48.8566,\\"longitude\\":2.3522}","name": "get_weather"},"type": "function","index": 0}]}}],"created": 1742452818,"model": "hunyuan-turbos-latest","object": "chat.completion","system_fingerprint": "","usage": {"completion_tokens": 48,"prompt_tokens": 22,"total_tokens": 70}}```第二次请求示例:```pythoncurl --location 'https://api.lkeap.tencentcloud.com/v1/chat/completions' \\-H "Content-Type: application/json" \\-H "Authorization: Bearer $API_KEY" \\--data '{"model": "deepseek-v3","messages": [{"role": "user","content": "What's the weather like in Paris today?"},{"role": "assistant","content": "调用天气查询工具(get_weather)来获取巴黎的天气信息。\\n\\t\\n\\t用户想要知道今天巴黎的天气。我需要调用天气查询工具(get_weather)来获取巴黎的天气信息。","tool_calls": [{"id": "call_cvdu67s2c3mafqgr1g6g","function": {"arguments": "{\\"latitude\\":48.8566,\\"longitude\\":2.3522}","name": "get_weather"},"type": "function","index": 0}]},{"role": "tool","tool_call_id": "call_cvdu67s2c3mafqgr1g6g","content": "11.7"}],"tools": [{"type": "function","function": {"name": "get_weather","description": "Get current temperature for provided coordinates in celsius.","parameters": {"type": "object","properties": {"latitude": {"type": "number"},"longitude": {"type": "number"}},"required": ["latitude","longitude"]}}}]}'```第二次响应示例:JSON```json{"id": "b03283653e27bc78a9c095699cfbc123","choices": [{"finish_reason": "stop","index": 0,"message": {"content": "The current temperature in Paris is 7.6°C.","role": "assistant"}}],"created": 1742453367,"model": "hunyuan-turbos-latest","object": "chat.completion","system_fingerprint": "","usage": {"completion_tokens": 24,"prompt_tokens": 71,"total_tokens": 95},"note": "以上内容为AI生成,不代表开发者立场,请勿删除或修改本标记"}```之后可以继续进行对话。
{"error":{"message":"not enough quota","type":"runtime_error","param":null,"code":"20031"}}
文档反馈