官网文档:https://platform.openai.com/docs/api-reference/introduction
一、Audio 类
文本转音频、音频转文本。
1.1、Create speech
POST https://api.openai.com/v1/audio/speech
功能:文本转音频。
1.2、Create transcription
POST https://api.openai.com/v1/audio/transcriptions
功能:音频转文本。
可用模型:仅 whisper-1 支持。
1.3、Create translation
POST https://api.openai.com/v1/audio/translations
功能:将音频翻译成英语。
可用模型:仅 whisper-1 支持。
二、 Chat 类
给定包含对话的消息列表,模型将返回响应。
2.1、Create chat completion
[POST] https://api.openai.com/v1/chat/completions
功能:聊天模型。根据给定的聊天对话作为输入,返回一个模型生成的消息作为输出。
可用模型:gpt-4 and dated model releases, gpt-4-1106-preview, gpt-4-vision-preview, gpt-4-32k and dated model releases, gpt-3.5-turbo and dated model releases, gpt-3.5-turbo-16k and dated model releases, fine-tuned versions of gpt-3.5-turbo。
三、Completion 类
给出提示后,模型将返回一个或多个预测完成,并且还可以返回每个位置的替代标记的概率。
3.1、Create completion
POST https://api.openai.com/v1/completions
功能:根据提供的提示词和参数创建补全。用户输入一段提示文字,模型按照文字的提示,给出对应的输出,可以理解为诱导型的对话。
可用模型:gpt-3.5-turbo-instruct, babbage-002, davinci-002。
注:Chat和Completion类API其实差别不大,通过不同的prompt可以达到相似的效果。只是Chat为对话显示定义了三个新角色:system、user、assistant。
四、Embeddings 类
文本嵌入衡量文本字符串的相关性
4.1、Create embeddings
POST https://api.openai.com/v1/embeddings
功能:创建表示输入文本的嵌入向量。
可用模型:text-embedding-ada-002。
五、Fine-tuning 类
管理微调作业,并根据您的特定训练数据定制模型。
接口名称 | 接口url | 接口功能介绍 |
---|---|---|
Create fine-tuning job | POST**https://****api.openai.com/v1/fine_**tuning/jobs | 创建一个job,创建一个作业,根据给定的数据集微调指定的模型。 |
List fine-tuning jobs | GET**https://****api.openai.com/v1/fine_**tuning/jobs | 列出您组织的微调工作。 |
Retrieve fine-tuning job | GEThttps://****api.openai.com/v1/fine_****tuning/jobs/{fine_tuning_job_id} | 获取有关微调工作的信息。 |
Cancel fine-tuning | POSThttps://****api.openai.com/v1/fine_****tuning/jobs/{fine_tuning_job_id}/cancel | 取消微调工作。 |
List fine-tuning events | GEThttps://****api.openai.com/v1/fine_****tuning/jobs/{fine_tuning_job_id}/events | 获取微调作业的状态更新。 |
注:上述所有接口可用模型为:gpt-3.5-turbo, babbage-002, davinci-002 。
六、Files 类
文件系统。上传文件,可用于人工智能助手、微调等功能。
接口名称 | 接口Url | 接口功能介绍 |
---|---|---|
List files | GET**https://**api.openai.com/v1/files | 当前用户组织的文件列表。 |
Upload files | POST**https://**api.openai.com/v1/files | 上传文件,可跨多个端点。一个组织上传的所有文件大小最大可达100GB. |
Delete file | GEThttps://api.openai.com/v1/files/{file_id} | 删除文件。 |
Retrieve file | GEThttps://api.openai.com/v1/files/{file_id} | 返回有关特定文件的信息。 |
Retrieve file content | GEThttps://api.openai.com/v1/files/{file_id}/content | 返回指定文件的内容。 |
七、Images 类
给定提示和/或输入图像,模型将生成新图像。
接口名称 | 接口url | 接口功能介绍 |
---|---|---|
Create image | POSThttps://api.openai.com/v1/images/generations | 根据提示创建图像。 |
Create image edit | POSThttps://api.openai.com/v1/images/edits | 对原始图像进行编辑和扩展。 |
Create image variation | POSThttps://api.openai.com/v1/images/variations | 创建给定图像的变体。 |
注:上述3个接口的可用模型均为:dall-e-2,dall-e-3。
八、Models 类
列出并描述所有可用的模型。 您可以参考模型文档来了解可用的模型以及它们之间的差异。
8.1、List models
GET https://api.openai.com/v1/models
功能:列出当前可用的模型,并提供每个模型的基本信息。
8.2、Retrieve model
GET https://api.openai.com/v1/models/{model}
功能:检索模型,提供查询模型的基本信息,例如所有者和权限。
8.3、Delete fine-tune model
Delete https://api.openai.com/v1/models/{model}
功能:删除微调模型。 您必须在组织中具有所有者角色才能删除模型。
九、Moderations 类
给定输入文本,判断输入的内容是否违反 OpenAI 的各项内容政策。
9.1、Create moderation
POST https://api.openai.com/v1/moderations
功能:对文本是否违反 OpenAI 的内容政策进行分类。
可用模型:text-moderation-stable
,text-moderation-latest
十、Assistants 类
构建可以调用模型并使用工具执行任务的助手。
接口名称 | 接口url | 接口功能介绍 |
---|---|---|
Create assistant | POSThttps://api.openai.com/v1/assistants | 创建一个带有模型和说明的助手。 |
Retrieve assistant | GEThttps://api.openai.com/v1/assistants/{assistant_id} | 检索人工智能助手。 |
Modify assistant | POSThttps://api.openai.com/v1/assistants/{assistant_id} | 修改人工智能助手。 |
Delete assistant | DELETEhttps://api.openai.com/v1/assistants/{assistant_id} | 删除人工智能助手。 |
List assistants | GEThttps://api.openai.com/v1/assistants | 人工智能助手列表。 |
Create assistant file | POSThttps://api.openai.com/v1/assistants/{assistant_id}/files | 通过将文件附加到助手来创建助手文件。 |
Retrieve assistant file | GEThttps://api.openai.com/v1/assistants/{assistant_id}/files/{file_id} | 检索人工智能助手文件。 |
Delete assistant file | DELETEhttps://api.openai.com/v1/assistants/{assistant_id}/files/{file_id} | 删除人工智能助手文件。 |
List assistant files | GEThttps://api.openai.com/v1/assistants/{assistant_id}/files | 返回辅助文件的列表。 |
其中:Create assistant、Retrieve assistant 和 Modify assistant 这3个接口可用模型为:所有模型除 gpt-3.5-turbo-0301
模型之外,检索工具可用模型有 gpt-4-1106-preview
or gpt-3.5-turbo-1106
。
十一、Threads 类
创建助手可以与之交互的线程。
接口名称 | 接口url | 接口功能介绍 |
---|---|---|
Create thread | POSThttps://api.openai.com/v1/threads | 创建一个线程。 |
Retrieve thread | GEThttps://api.openai.com/v1/threads/{thread_id} | 检索线程。 |
Modify thread | POSThttps://api.openai.com/v1/threads/{thread_id} | 修改线程。 |
Delete thread | DELETEhttps://api.openai.com/v1/threads/{thread_id} | 删除线程。 |
十二、Messages 类
在线程中创建消息
接口名称 | 接口url | 接口功能介绍 |
---|---|---|
Create message | POSThttps://api.openai.com/v1/threads/{thread_id}/messages | 创建消息。 |
Retrieve message | GEThttps://api.openai.com/v1/threads/{thread_id}/messages/{message_id} | 检索信息。 |
Modify message | POSThttps://api.openai.com/v1/threads/{thread_id}/messages/{message_id} | 修改信息。 |
List messages | GEThttps://api.openai.com/v1/threads/{thread_id}/messages | 消息列表。 |
Retrieve message file | GEThttps://api.openai.com/v1/threads/{thread_id}/messages/{message_id}/files/{file_id} | 检索消息文件。 |
List message files | GEThttps://api.openai.com/v1/threads/{thread_id}/messages/{message_id}/files | 返回消息文件列表。 |
十三、Runs类
表示在线程上运行的进程。
接口名称 | 接口url | 接口功能介绍 |
---|---|---|
Create run | POSThttps://api.openai.com/v1/threads/{thread_id}/runs | 创建进程。 |
Retrieve run | GEThttps://api.openai.com/v1/threads/{thread_id}/runs/{run_id} | 检索进程。 |
Modify run | POSThttps://api.openai.com/v1/threads/{thread_id}/runs/{run_id} | 修改进程。 |
List runs | GEThttps://api.openai.com/v1/threads/{thread_id}/runs | 返回属于线程的进程列表。 |
Submit tool outputs to run | POSThttps://api.openai.com/v1/threads/{thread_id}/runs/{run_id}/submit_tool_outputs | 当运行状态中有 "requires_action" 、"required_action. type"、"submit_tool_outputs",一旦工具调用全部完成,此端点可用于提交工具调用的输出。所有输出必须在单个请求中提交 |
Cancel a run | POSThttps://api.openai.com/v1/threads/{thread_id}/runs/{run_id}/cancel | 取消运行中的进程。 |
Create thread and run | POSThttps://api.openai.com/v1/threads/runs | 创建一个线程并在一个请求中运行它。 |
Retrieve run step | GEThttps://api.openai.com/v1/threads/{thread_id}/runs/{run_id}/steps/{step_id} | 检索运行步骤。 |
List run steps | GET``https://api.openai.com/v1/threads/{thread_id}/runs/{run_id}/steps | 返回属于某个进程的运行步骤的列表。 |