openAI API接口文档查看地址 https://platform.openai.com/docs/api-reference/making-requests
如果打不开open AI 的链接,就勉强看看下面的例子吧,附件为API文档
1. 聊天接口
请求JSON
curl https://api.openai.com/v1/chat/completions
-H “Content-Type: application/json”
-H “Authorization: Bearer $OPENAI_API_KEY”
-d ‘{
“model”: “gpt-3.5-turbo”,
“messages”: [{“role”: “user”, “content”: “Say this is a test!”}],
“temperature”: 0.7
}’
响应JSON
{
“id”:”chatcmpl-abc123″,
“object”:”chat.completion”,
“created”:1677858242,
“model”:”gpt-3.5-turbo-0301″,
“usage”:{
“prompt_tokens”:13,
“completion_tokens”:7,
“total_tokens”:20
},
“choices”:[
{
“message”:{
“role”:”assistant”,
“content”:”nnThis is a test!”
},
“finish_reason”:”stop”,
“index”:0
}
]
}
2. 列出可用的模型
curl https://api.openai.com/v1/models
-H “Authorization: Bearer $OPENAI_API_KEY”
响应JSON
{
“data”: [
{
“id”: “model-id-0”,
“object”: “model”,
“owned_by”: “organization-owner”,
“permission”: […]
},
{
“id”: “model-id-1”,
“object”: “model”,
“owned_by”: “organization-owner”,
“permission”: […]
},
{
“id”: “model-id-2”,
“object”: “model”,
“owned_by”: “openai”,
“permission”: […]
},
],
“object”: “list”
}
3. 检索模型
curl https://api.openai.com/v1/models/text-davinci-003
-H “Authorization: Bearer $OPENAI_API_KEY”
响应JSON
{
“id”: “text-davinci-003”,
“object”: “model”,
“owned_by”: “openai”,
“permission”: […]
}
4. 一般的请求接口
curl https://api.openai.com/v1/completions
-H “Content-Type: application/json”
-H “Authorization: Bearer $OPENAI_API_KEY”
-d ‘{
“model”: “text-davinci-003”,
“prompt”: “Say this is a test”,
“max_tokens”: 7,
“temperature”: 0
}’
响应示例
{
“id”: “cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7”,
“object”: “text_completion”,
“created”: 1589478378,
“model”: “text-davinci-003”,
“choices”: [
{
“text”: “nnThis is indeed a test”,
“index”: 0,
“logprobs”: null,
“finish_reason”: “length”
}
],
“usage”: {
“prompt_tokens”: 5,
“completion_tokens”: 7,
“total_tokens”: 12
}
}
5. 聊天接口
curl https://api.openai.com/v1/chat/completions
-H “Content-Type: application/json”
-H “Authorization: Bearer $OPENAI_API_KEY”
-d ‘{
“model”: “gpt-3.5-turbo”,
“messages”: [{“role”: “user”, “content”: “Hello!”}]
}’
响应示例
{
“id”: “chatcmpl-123”,
“object”: “chat.completion”,
“created”: 1677652288,
“choices”: [{
“index”: 0,
“message”: {
“role”: “assistant”,
“content”: “nnHello there, how may I assist you today?”,
},
“finish_reason”: “stop”
}],
“usage”: {
“prompt_tokens”: 9,
“completion_tokens”: 12,
“total_tokens”: 21
}
}
6. 图像
curl https://api.openai.com/v1/images/variations
-H “Authorization: Bearer $OPENAI_API_KEY”
-F image=”@otter.png”
-F n=2
-F size=”1024×1024″
响应示例
{
“created”: 1589478378,
“data”: [
{
“url”: “https://…”
},
{
“url”: “https://…”
}
]
}
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
摘要:本文结合Karmada社区对大规模场景的思考,揭示Karmada稳定支持100个大规模集群、管理超过50万个节点和200万个Pod背后的原理 本文分享自华为云社区《Karmada百倍集群规模多云基础设施体系揭秘》,作者: 云容器大未来 。 随着云原生技术…