每日签到奶昔超市点数市场奶昔访达
返回列表 发布新帖
查看: 731|回复: 1

算能 SophNet 免费 DeepSeek R1 满血 API

发表于 2025-4-13 15:05:17 | 查看全部 |阅读模式

欢迎注册论坛,享受更多奶昔会员权益!

您需要 登录 才可以下载或查看,没有账号?注册

×
今天又发现一家免费的第三方 DeepSeek R1 API,注册就有免费额度 50¥(现在缩减到 20¥了,而且多了个邀请码机制,不过被邀请的没有额外额度
https://sophnet.com/#/model/overview
官网标参数如下:
8cbb5079db65a2bf7abc577166ed3edd.jpg
实测速度非常快,比华为云和腾讯云 LKEAP 都快,推理信息放在 reasoning_content 字段。
懒得注册的自己玩,附上脚本
  1. import requests
  2. import time
  3. from concurrent.futures import ThreadPoolExecutor
  4. import logging
  5. from datetime import datetime

  6. # 配置日志
  7. logging.basicConfig(
  8.     level=logging.INFO,
  9.     format='%(asctime)s - %(threadName)s - %(message)s'
  10. )

  11. # 定义常量
  12. TOKEN = ''
  13. PROJECT_ID = '887100'
  14. PROJECT_TYPE = '1'

  15. # 获取手机号码

  16. def get_mobile():
  17.     print('请求获取手机号码...')
  18.     response = requests.post('http://h5.do889.com:81/api/get_mobile', data={
  19.         'token': TOKEN + ';project_id=' + PROJECT_ID + ';project_type=' + PROJECT_TYPE + ';operator=0;loop=1',
  20.     })
  21.     print(f'获取手机号码请求的响应: {response.status_code}, 内容: {response.text}')
  22.     mobile_data = response.json()
  23.     return mobile_data.get('mobile')

  24. # 发送验证码请求

  25. def send_code(phone_number):
  26.     print('请求发送验证码...')
  27.     code_response = requests.post('https://sophnet.com/api/sys/code', json={
  28.         'phoneNumber': phone_number
  29.     })
  30.     print(f'发送验证码请求的响应: {code_response.status_code}, 内容: {code_response.text}')
  31.     return code_response

  32. # 轮询获取短信

  33. def poll_for_sms(phone_number):
  34.     print('开始轮询获取短信...')
  35.     start_time = time.time()  # 记录开始时间
  36.     while True:
  37.         message_response = requests.post('http://h5.do889.com:81/api/get_message', data={
  38.             'token': TOKEN + ';phone_num=' + phone_number + ';project_type=' + PROJECT_TYPE + ';project_id=' + PROJECT_ID
  39.         })
  40.         print(f'获取短信请求的响应: {message_response.status_code}, 内容: {message_response.text}')
  41.         message_data = message_response.json()
  42.         if message_data['message'] == '短信还未到达,请继续获取':
  43.             print('短信还未到达,继续轮询...')
  44.             if time.time() - start_time > 30:  # 检查是否超过 30 秒
  45.                 print('超过 30 秒未收到短信,跳过此次...')
  46.                 return None
  47.             time.sleep(5)  # 等待 5 秒后重试
  48.         else:
  49.             code = message_data['data'][0]['modle'].split('验证码:')[1].split(',')[0]
  50.             print(f'获取到的验证码: {code}')
  51.             return code

  52. # 登录并获取 access token

  53. def login(phone_number, code):
  54.     print('请求登录并获取 access token...')
  55.     login_response = requests.post('https://sophnet.com/api/sys/login/code', json={
  56.         'phoneNumber': phone_number,
  57.         'code': code,
  58.         'password': ''
  59.     })
  60.     print(f'登录请求的响应: {login_response.status_code}, 内容: {login_response.text}')
  61.     return login_response.json()['result']['token']

  62. # 获取组织ID

  63. def get_org_id(access_token):
  64.     print('获取组织ID...')
  65.     org_response = requests.get('https://sophnet.com/api/orgs/joined-org', headers={
  66.         'Authorization': f'Bearer {access_token}'
  67.     })
  68.     print(f'获取组织ID响应: {org_response.status_code}, 内容: {org_response.text}')
  69.     return org_response.json()['result']['list'][0]['id']

  70. # 获取项目ID

  71. def get_project_id(org_id, access_token):
  72.     print('获取项目ID...')
  73.     project_response = requests.get(f'https://sophnet.com/api/orgs/{org_id}/projects', params={
  74.         'pageNum': 1,
  75.         'pageSize': 99999
  76.     }, headers={
  77.         'Authorization': f'Bearer {access_token}'
  78.     })
  79.     print(f'获取项目ID响应: {project_response.status_code}, 内容: {project_response.text}')
  80.     return project_response.json()['result']['list'][0]['id']

  81. # 请求服务

  82. def request_service(project_id, access_token, display_model_id):
  83.     print('请求服务...')
  84.     service_response = requests.post(f'https://sophnet.com/api/projects/{project_id}/service', json={
  85.         "displayModelId": display_model_id,
  86.         "llmType": "ChatCompletion",
  87.         "quota": 200
  88.     }, headers={
  89.         'Authorization': f'Bearer {access_token}'
  90.     })
  91.     print(f'请求服务响应: {service_response.status_code}, 内容: {service_response.text}')
  92.     return service_response

  93. # 请求 API Key

  94. def request_api_key(project_id, access_token):
  95.     print('请求服务以获取 API Key...')
  96.     api_key_response = requests.post(f'https://sophnet.com/api/projects/{project_id}/apikey', headers={
  97.         'Authorization': f'Bearer {access_token}'
  98.     }, json={
  99.         'name': 'API Key'
  100.     })
  101.     print(f'获取 API Key 请求的响应: {api_key_response.status_code}, 内容: {api_key_response.text}')
  102.     return api_key_response.json()['result']['apikey']

  103. def process_single_flow():
  104.     """执行单个完整的流程"""
  105.     try:
  106.         phone_number = get_mobile()
  107.         if not phone_number:
  108.             logging.info("获取手机号失败")
  109.             return

  110.         code_response = send_code(phone_number)
  111.         if not code_response:
  112.             logging.info(f"发送验证码失败: {phone_number}")
  113.             return

  114.         code = poll_for_sms(phone_number)
  115.         if not code:
  116.             logging.info(f"获取验证码失败: {phone_number}")
  117.             return

  118.         access_token = login(phone_number, code)
  119.         if not access_token:
  120.             logging.info(f"登录失败: {phone_number}")
  121.             return

  122.         org_id = get_org_id(access_token)
  123.         if not org_id:
  124.             logging.info(f"获取组织ID失败: {phone_number}")
  125.             return

  126.         project_id = get_project_id(org_id, access_token)
  127.         if not project_id:
  128.             logging.info(f"获取项目ID失败: {phone_number}")
  129.             return

  130.         # 并发执行服务请求和API密钥获取
  131.         with ThreadPoolExecutor() as executor:
  132.             # 先执行服务请求
  133.             service_futures = [
  134.                 executor.submit(request_service, project_id, access_token, 11),
  135.                 executor.submit(request_service, project_id, access_token, 6)
  136.             ]
  137.             # 等待服务请求完成
  138.             for future in service_futures:
  139.                 service_response = future.result()
  140.                 if not service_response:
  141.                     logging.error("服务请求失败")
  142.                     return False
  143.             
  144.             # 获取API密钥
  145.             api_key_future = executor.submit(request_api_key, project_id, access_token)
  146.             api_key = api_key_future.result()
  147.             if api_key:
  148.                 with open('result.txt', 'a') as f:
  149.                     f.write(api_key + '\n')  # 保存 API 密钥
  150.                 logging.info(f"API Key 已保存: {phone_number}")
  151.             else:
  152.                 logging.error("获取 API Key 失败")
  153.                 return False

  154.         logging.info(f"流程完成: {phone_number}")
  155.         return True

  156.     except Exception as e:
  157.         logging.error(f"流程出错: {str(e)}")
  158.         return False

  159. def main(concurrent_flows=5):
  160.     """
  161.     主函数,控制并发流程数量,当一个流程完成后立即启动新的流程
  162.     :param concurrent_flows: 最大并发流程数量
  163.     """
  164.     logging.info(f"开始运行,最大并发数: {concurrent_flows}")
  165.    
  166.     # 创建一个长期运行的线程池
  167.     with ThreadPoolExecutor(max_workers=concurrent_flows) as executor:
  168.         running_futures = set()
  169.         
  170.         while True:
  171.             # 检查并移除已完成的任务
  172.             done_futures = {f for f in running_futures if f.done()}
  173.             for future in done_futures:
  174.                 try:
  175.                     result = future.result()
  176.                     if result:
  177.                         logging.info("一个流程成功完成")
  178.                     else:
  179.                         logging.info("一个流程失败")
  180.                 except Exception as e:
  181.                     logging.error(f"流程执行出错: {str(e)}")
  182.                 running_futures.remove(future)
  183.             
  184.             # 当有空闲线程时,立即启动新的流程
  185.             while len(running_futures) < concurrent_flows:
  186.                 new_future = executor.submit(process_single_flow)
  187.                 running_futures.add(new_future)
  188.                 logging.info("启动新的流程")
  189.             
  190.             # 短暂休眠以避免CPU过度使用
  191.             time.sleep(0.1)

  192. if __name__ == "__main__":
  193.     # 设置并发数量为5,您可以根据需要调整这个数字
  194.     main(concurrent_flows=20)
复制代码
爱生活,爱奶昔~
回复

使用道具 举报

发表于 2025-4-13 15:05:51 | 查看全部
备案的,高级模型还只有v3和r1感觉没必要
爱生活,爱奶昔~
您需要登录后才可以回帖 登录 | 注册

本版积分规则

© 2025 Nyarime 沪ICP备13020230号-1|沪公网安备 31010702007642号手机版小黑屋RSS
返回顶部 关灯 在本版发帖
快速回复 返回顶部 返回列表