OpenAI ChatGPT 4 API 的 使用
#### GPT4 API接口调用方式,范例
发起调用:
```bash
curl https://ENDPOINT/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $APIKEY" \
-d '{
"model": "gpt-4",
"messages": [{"role": "user", "content": "短文描写,下雨天慵懒的心情。"}]
}'
```
返回:
```bash
{
"choices" : [
{
"finish_reason" : "stop",
"index" : 0,
"message" : {
"content" : "雨滴轻敲着窗,蜿蜒的水珠凌乱地滑落。温暖的被窝里,悠闲慵懒,静享这悠长的雨日时光。",
"role" : "assistant"
}
}
],
"created" : 1683157218,
"id" : "chatcmpl-7CgNuwVbn41tbK3HtLJ",
"model" : "gpt-4-0314",
"object" : "chat.completion",
"usage" : {
"completion_tokens" : 68,
"prompt_tokens" : 28,
"total_tokens" : 96
}
}
```
需要ChatGPT 4 API 权限的用户,可以在本站后台获取。