v1

latestOpenAPI 3.1.0Proprietary2026-07-2662032.5 KB
Edit

Create a code edit completion

Generate an edit to a code region given the surrounding context. The request must contain a single user message whose content includes the required edit prompt tags (e.g. <|code_to_edit|>, <|cursor|>, <|current_file_content|>). Returns an EditCompletion object. Streaming and tool calling are not supported on this endpoint.

post/v1/edit/completions

Request body

modelstring required

The model to use for the edit completion.

max_tokensinteger

Maximum number of tokens to generate.

temperaturenumber

What sampling temperature to use, between 0 and 2. Higher values make the output more random; lower values make it more focused and deterministic.

top_pnumber

Float that controls the cumulative probability of the top tokens to consider.

presence_penaltynumber

Number between -2 and 2. Positive values penalize tokens based on whether they have appeared in the text so far, increasing the model's likelihood to talk about new topics.

Response

Successful Response

idstring required
object'edit.completion' required
createdinteger required
modelstring required
warningstring nullable

Example response

{
  "id": "cmpl-7a2b3c4d5e",
  "object": "edit.completion",
  "created": 1745798400,
  "model": "mercury-edit-2",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "def greet(name):\n    print(f\"hi {name}\")\n"
      }
    }
  ],
  "usage": {
    "prompt_tokens": 156,
    "completion_tokens": 18,
    "total_tokens": 174,
    "reasoning_tokens": 0,
    "cached_input_tokens": 0
  }
}
All 6 operations