发一个可用的免费 deepseek-r1 api接口

发一个 deepseek-r1 的api接口

openai 的api格式调用

网址
http://api.bingapi.us.kg:2095/v1/chat/completions

密钥
Authorization: Bearer op_Fu0vdY7Gjko69IkYlg69Fr

模型名称 deepseek-r1

注意是http,不是https。不支持流式输出。r1模型思考加推理返回响应通常需要20秒到1分钟。

国内访问丢包严重,经常出现api报错:ConnectionError: (‘Connection aborted.’, ConnectionResetError(10054, ‘远程主机强迫关闭了一个现有的连接。’, None, 10054, None))
原因分析:被墙了,请挂代理访问api。

调用代码如下

import requests
import json

def call_deepseek_api(messages):

url = "http://api.bingapi.us.kg:2095/v1/chat/completions"
headers = {
    "Authorization": "Bearer op_Fu0vdY7Gjko69IkYlg69Fr",
    "Content-Type": "application/json"
}
data = {
    "model": "deepseek-r1",
    "messages": messages
}

try:
    response = requests.post(url, headers=headers, data=json.dumps(data), timeout=300)
    response.raise_for_status()  # Raise an exception for bad status codes (4xx or 5xx)
    return response.text # Return the raw text response
except requests.exceptions.RequestException as e:
    print(f"Error calling DeepSeek API: {e}")
    return None

messages = [
{“role”: “system”, “content”: “You are a helpful assistant.”},
{“role”: “user”, “content”: “写个汽车广告”}
]

response = call_deepseek_api(messages)

if response:
print(response) # Print the raw response body

25 个赞

感谢分享

1 个赞

感谢分享

1 个赞

谢谢分享

感谢分享

感谢大佬!

感谢大佬分享

Bad gateway Error code 502

感谢分享

可以用,直接运行示例代码,最好开代理访问

感谢大佬分享

感谢分享

感谢分享


沉浸式翻译测试能通过,但是没有输出,估计被限制了

感谢分享

检查了一下,沉浸式翻译,ai已经作出了响应,只是输出有think这样的思考过程,导致翻译软件适配不了deepseek-r1的输出格式,无法获取到正确的内容