|
楼主 |
发表于 2025-5-18 01:09:29
|
查看全部
KEY:
- eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYxZjk1NWQwLTdmOWMtNGQ2Yy1hNGM4LTBkNjU1NTEyYTIzMCIsInR5cGUiOiJpZV9tb2RlbCJ9.fkIGAAlmcuvRo0RjoNhqAGWphvUTpACTnNvBfPUvFnQ
复制代码
建议使用模型:
- Qwen/Qwen3-235B-A22B-FP8、deepseek-ai/DeepSeek-R1、deepseek-ai/DeepSeek-V3-0324
复制代码
请求示例:
- import requests
- import json
- api_key = “eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjYxZjk1NWQwLTdmOWMtNGQ2Yy1hNGM4LTBkNjU1NTEyYTIzMCIsInR5cGUiOiJpZV9tb2RlbCJ9.fkIGAAlmcuvRo0RjoNhqAGWphvUTpACTnNvBfPUvFnQ”
- chat_url = “https://api.gmi-serving.com/v1/chat/completions”
- headers = {
- “Authorization”: f"Bearer {api_key}",
- “Content-Type”: “application/json”
- }
- user_message_content = input(“请输入消息:”)
- payload = {
- “model”: “deepseek-ai/DeepSeek-R1”,
- “messages”: [
- {“role”: “user”, “content”: user_message_content}
- ],
- “max_tokens”: 2000,
- “temperature”: 1.0
- }
- response = requests.post(chat_url, headers=headers, json=payload)
- response.raise_for_status()
- print(json.dumps(response.json(), indent=2, ensure_ascii=False))
复制代码
返回结果:
请输入消息:hi
- {
- “id”: “38e9e17fd0a142219a17a10105e9e915”,
- “object”: “chat.completion”,
- “created”: 1747500437,
- “model”: “deepseek-ai/DeepSeek-R1”,
- “choices”: [
- {
- “index”: 0,
- “message”: {
- “role”: “assistant”,
- “content”: “Hi there! :waving_hand: How can I assist you today?”,
- “reasoning_content”: “Okay, the user just said "hi". I need to respond friendly and welcome them. Maybe ask how I can assist them today. Keep it open so they feel comfortable to ask anything. Make sure the tone is warm and approachable. Also, check for any specific emojis or punctuation to keep it casual but professional.\n”,
- “tool_calls”: null
- },
- “logprobs”: null,
- “finish_reason”: “stop”,
- “matched_stop”: 1
- }
- ],
- “usage”: {
- “prompt_tokens”: 6,
- “total_tokens”: 87,
- “completion_tokens”: 81,
- “prompt_tokens_details”: null
- }
- }
复制代码 |
|