API文档(api-reference)
编辑(Edits)

编辑Edits

在给定提示和指令的情况下,模型将返回提示的编辑版本。

创建编辑Create edit发布 https://api.openai.com/v1/edits (opens in a new tab)

为提供的输入,指令和参数创建新的编辑。

请求正文

model 是字符串类型的必填项,表示要使用的模型的ID。您可以在该端点上使用 text-davinci-edit-001code-davinci-edit-001 模型。

input 是字符串类型的可选项。默认为 ''。表示用作编辑起点的输入文本。

instruction 是字符串类型的必填项,指示模型如何进行编辑。

n 是整数类型的可选项。默认为 1。表示要为输入和指令生成多少次编辑。

temperature 是数字类型的可选项。默认为 1,取值范围在0到2之间。较高的值(例如0.8)会使输出更加随机化,而较低的值(例如0.2)会使其更加集中和确定。

注:inputinstructiontemperaturemodel是技术专业词汇,不需要翻译。

我们通常建议更改此项或 top_p ,而不是同时更改两者。

top_p 是数字类型的可选参数。默认为1。与温度(temperature)采样相比的替代方案称为中心采样,该方法使得模型只考虑概率质量前 top_p 个标记结果。因此, 0.1 表示只考虑概率质量前 10% 的标记。

我们通常建议更改此项或 temperature ,而不是同时更改两者。

请求示例(Example request)

 curl https://api.openai.com/v1/edits 
  -H "Content-Type: application/json" 
  -H "Authorization: Bearer $OPENAI_API_KEY" 
  -d '{
    "model": "text-davinci-edit-001",
    "input": "What day of the wek is it?",
    "instruction": "Fix the spelling mistakes"
  }'

请求参数(Parameters)

 {
 "model": "text-davinci-edit-001",
 "input": "What day of the wek is it?",
 "instruction": "Fix the spelling mistakes",
}

响应体 (Response)

 {
 "object": "edit",
 "created": 1589478378,
 "choices": [
    {
 "text": "What day of the week is it?",
 "index": 0,
    }
  ],
 "usage": {
 "prompt_tokens": 25,
 "completion_tokens": 32,
 "total_tokens": 57
  }
}