> For the complete documentation index, see [llms.txt](https://docs.luojixiangliang.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.luojixiangliang.com/reference/openai-api-can-kao-wen-dang/bian-ji.md).

# 编辑

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

### 创建编辑

```
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，但不要同时更改两个。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.luojixiangliang.com/reference/openai-api-can-kao-wen-dang/bian-ji.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
