gongdear

gongdear的技术博客

欢迎大家参观我的博客
  menu
107 文章
89355 浏览
2 当前访客
ღゝ◡╹)ノ❤️

OpenAI API接口汇总

官网文档:https://platform.openai.com/docs/api-reference/introduction

一、Audio 类

文本转音频、音频转文本。

1.1、Create speech

POST   https://api.openai.com/v1/audio/speech

功能:文本转音频。

可用模型:tts-1tts-1-hd

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 jobPOST**https://****api.openai.com/v1/fine_**tuning/jobs创建一个job,创建一个作业,根据给定的数据集微调指定的模型。
List fine-tuning jobsGET**https://****api.openai.com/v1/fine_**tuning/jobs列出您组织的微调工作。
Retrieve fine-tuning jobGEThttps://****api.openai.com/v1/fine_****tuning/jobs/{fine_tuning_job_id}获取有关微调工作的信息。
Cancel fine-tuningPOSThttps://****api.openai.com/v1/fine_****tuning/jobs/{fine_tuning_job_id}/cancel取消微调工作。
List fine-tuning eventsGEThttps://****api.openai.com/v1/fine_****tuning/jobs/{fine_tuning_job_id}/events获取微调作业的状态更新。

注:上述所有接口可用模型为:gpt-3.5-turbo, babbage-002, davinci-002

六、Files 类

文件系统。上传文件,可用于人工智能助手、微调等功能。

接口名称接口Url接口功能介绍
List filesGET**https://**api.openai.com/v1/files当前用户组织的文件列表。
Upload filesPOST**https://**api.openai.com/v1/files上传文件,可跨多个端点。一个组织上传的所有文件大小最大可达100GB.
Delete fileGEThttps://api.openai.com/v1/files/{file_id}删除文件。
Retrieve fileGEThttps://api.openai.com/v1/files/{file_id}返回有关特定文件的信息。
Retrieve file contentGEThttps://api.openai.com/v1/files/{file_id}/content返回指定文件的内容。

七、Images 类

给定提示和/或输入图像,模型将生成新图像。

接口名称接口url接口功能介绍
Create imagePOSThttps://api.openai.com/v1/images/generations根据提示创建图像。
Create image editPOSThttps://api.openai.com/v1/images/edits对原始图像进行编辑和扩展。
Create image variationPOSThttps://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 assistantPOSThttps://api.openai.com/v1/assistants创建一个带有模型和说明的助手。
Retrieve assistantGEThttps://api.openai.com/v1/assistants/{assistant_id}检索人工智能助手。
Modify assistantPOSThttps://api.openai.com/v1/assistants/{assistant_id}修改人工智能助手。
Delete assistantDELETEhttps://api.openai.com/v1/assistants/{assistant_id}删除人工智能助手。
List assistantsGEThttps://api.openai.com/v1/assistants人工智能助手列表。
Create assistant filePOSThttps://api.openai.com/v1/assistants/{assistant_id}/files通过将文件附加到助手来创建助手文件。
Retrieve assistant fileGEThttps://api.openai.com/v1/assistants/{assistant_id}/files/{file_id}检索人工智能助手文件。
Delete assistant fileDELETEhttps://api.openai.com/v1/assistants/{assistant_id}/files/{file_id}删除人工智能助手文件。
List assistant filesGEThttps://api.openai.com/v1/assistants/{assistant_id}/files返回辅助文件的列表。

其中:Create assistant、Retrieve assistant 和 Modify assistant 这3个接口可用模型为:所有模型除 gpt-3.5-turbo-0301模型之外,检索工具可用模型有 gpt-4-1106-previewor gpt-3.5-turbo-1106

十一、Threads

创建助手可以与之交互的线程。

接口名称接口url接口功能介绍
Create threadPOSThttps://api.openai.com/v1/threads创建一个线程。
Retrieve threadGEThttps://api.openai.com/v1/threads/{thread_id}检索线程。
Modify threadPOSThttps://api.openai.com/v1/threads/{thread_id}修改线程。
Delete threadDELETEhttps://api.openai.com/v1/threads/{thread_id}删除线程。

十二、Messages

在线程中创建消息

接口名称接口url接口功能介绍
Create messagePOSThttps://api.openai.com/v1/threads/{thread_id}/messages创建消息。
Retrieve messageGEThttps://api.openai.com/v1/threads/{thread_id}/messages/{message_id}检索信息。
Modify messagePOSThttps://api.openai.com/v1/threads/{thread_id}/messages/{message_id}修改信息。
List messagesGEThttps://api.openai.com/v1/threads/{thread_id}/messages消息列表。
Retrieve message fileGEThttps://api.openai.com/v1/threads/{thread_id}/messages/{message_id}/files/{file_id}检索消息文件。
List message filesGEThttps://api.openai.com/v1/threads/{thread_id}/messages/{message_id}/files返回消息文件列表。

十三、Runs

表示在线程上运行的进程。

接口名称接口url接口功能介绍
Create runPOSThttps://api.openai.com/v1/threads/{thread_id}/runs创建进程。
Retrieve runGEThttps://api.openai.com/v1/threads/{thread_id}/runs/{run_id}检索进程。
Modify runPOSThttps://api.openai.com/v1/threads/{thread_id}/runs/{run_id}修改进程。
List runsGEThttps://api.openai.com/v1/threads/{thread_id}/runs返回属于线程的进程列表。
Submit tool outputs to runPOSThttps://api.openai.com/v1/threads/{thread_id}/runs/{run_id}/submit_tool_outputs当运行状态中有 "requires_action" 、"required_action. type"、"submit_tool_outputs",一旦工具调用全部完成,此端点可用于提交工具调用的输出。所有输出必须在单个请求中提交
Cancel a runPOSThttps://api.openai.com/v1/threads/{thread_id}/runs/{run_id}/cancel取消运行中的进程。
Create thread and runPOSThttps://api.openai.com/v1/threads/runs创建一个线程并在一个请求中运行它。
Retrieve run stepGEThttps://api.openai.com/v1/threads/{thread_id}/runs/{run_id}/steps/{step_id}检索运行步骤。
List run stepsGET``https://api.openai.com/v1/threads/{thread_id}/runs/{run_id}/steps返回属于某个进程的运行步骤的列表。
宝剑锋从磨砺出,梅花香自苦寒来.