通过request非流式请求示例(chat示例)
import requests
import json
def get_chat_gpt_response(prompt):
url = "https://4.0.wokaai.com/v1/chat/completions"
headers = {
"Authorization": "Bearer apikey",
"Content-Type": "application/json"
}
data = {
"model": "claude-3-haiku-20240307",
"messages": [{"role": "user", "content": prompt}]
}
response = requests.post(url, headers=headers, json=data)
print(json.loads(response.text))
return response
resp = get_chat_gpt_response('给我画一个可爱的女生穿着绿色的卫衣')
print(resp.text)