千问开源大模型
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

26 lines
546 B

# coding=utf-8
import requests
import json
url = "https://api.openai.com/v1/chat/completions"
payload = json.dumps({
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "你好!"
}
]
})
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer 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'
}
response = requests.request("POST", url, headers=headers, data=payload)
# print(response.text)
r=json.loads(response.text)
# r=response.text
print(r['choices'][0]['message']['content'])