---
title: "Apply code edit"
method: PUT
path: "/codegen/fastapply/{path}"
tags: ["fastapply"]
---

# Apply code edit

`PUT /codegen/fastapply/{path}`

Uses the configured LLM provider (Relace or Morph) to apply a code edit to the original content.

To use this endpoint as an agent tool, follow these guidelines:

Use this tool to make an edit to an existing file. This will be read by a less intelligent model, which will quickly apply the edit. You should make it clear what the edit is, while also minimizing the unchanged code you write.

When writing the edit, you should specify each edit in sequence, with the special comment "// ... existing code ..." to represent unchanged code in between edited lines.

Example format:
// ... existing code ...
FIRST_EDIT
// ... existing code ...
SECOND_EDIT
// ... existing code ...
THIRD_EDIT
// ... existing code ...

You should still bias towards repeating as few lines of the original file as possible to convey the change. But, each edit should contain minimally sufficient context of unchanged lines around the code you're editing to resolve ambiguity.

DO NOT omit spans of pre-existing code (or comments) without using the "// ... existing code ..." comment to indicate its absence. If you omit the existing code comment, the model may inadvertently delete these lines.

If you plan on deleting a section, you must provide context before and after to delete it. If the initial code is "Block 1\nBlock 2\nBlock 3", and you want to remove Block 2, you would output "// ... existing code ...\nBlock 1\nBlock 3\n// ... existing code ...".

Make sure it is clear what the edit should be, and where it should be applied. Make edits to a file in a single edit_file call instead of multiple edit_file calls to the same file. The apply model can handle many distinct edits at once.

## Path parameters

- `path` string, required

## Request body

- ApplyEditRequest
  - `codeEdit` string, required
  - `model` string

## Response `200`

Code edit applied successfully

- ApplyEditResponse
  - `message` string
  - `originalContent` string
  - `path` string
  - `provider` string
  - `success` boolean
  - `updatedContent` string

## Other responses

- `400` — Invalid request
- `422` — Unprocessable entity - failed to process the request
- `503` — Service unavailable - no provider configured

---

[API](https://skmtc.net/blaxel/apis/blaxel-control-plane.md) · [All operations](https://skmtc.net/blaxel/apis/blaxel-control-plane/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/blaxel/blaxel-control-plane/versions/dfa264bc72ee/schema)
