# 编辑

给定提示和指令，模型将返回提示的编辑版本。

### 创建编辑

```
POST https://api.openai.com/v1/edits
```

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

#### 请求示例

{% tabs %}
{% tab title="curl" %}
{% code lineNumbers="true" %}

```sh
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"
  }'

```

{% endcode %}
{% endtab %}

{% tab title="python" %}
{% code lineNumbers="true" %}

```python
import os
import openai
openai.api_key = os.getenv("OPENAI_API_KEY")
openai.Edit.create(
  model="text-davinci-edit-001",
  input="What day of the wek is it?",
  instruction="Fix the spelling mistakes"
)

```

{% endcode %}
{% endtab %}

{% tab title="node.js" %}
{% code lineNumbers="true" %}

```javascript
const { Configuration, OpenAIApi } = require("openai");
const configuration = new Configuration({
  apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const response = await openai.createEdit({
  model: "text-davinci-edit-001",
  input: "What day of the wek is it?",
  instruction: "Fix the spelling mistakes",
});

```

{% endcode %}
{% endtab %}
{% endtabs %}

{% code title="请求参数" lineNumbers="true" %}

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

```

{% endcode %}

{% code title="返回结果" lineNumbers="true" %}

```json
{
  "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
  }
}
json
```

{% endcode %}

#### 请求主体

* model 字符串 必需 要使用的模型的ID。您可以在此端点中使用text-davinci-edit-001或code-davinci-edit-001模型。
* input 字符串 可选的 默认为'' 用作编辑起点的输入文本。
* instruction 字符串 必需 告诉模型如何编辑提示的指令。
* n 整数 可选的 默认为1 要为输入和指令生成多少个编辑。
* temperature 数字 可选的 默认为1 使用的采样温度，介于0和2之间。较高的值（例如0.8）将使输出更随机，而较低的值（例如0.2）将使其更加集中和确定性。

  我们通常建议更改这个或top\_p，但不要同时更改两个。
* top\_p： 数字 可选的 默认为1 与采用温度进行采样的另一种方法称为nucleus采样，其中模型考虑具有top\_p概率质量的令牌的结果。因此，0.1表示仅考虑组成前10％概率质量的令牌。

  我们通常建议更改这个或temperature，但不要同时更改两个。
