Apply a unified diff produced by the model directly to a code block within the same conversation.
Not yet available. The Apply Patch server tool is not yet available.
When a model produces a unified diff in response to a code-editing request, Apply Patch takes that diff and applies it to the original code block server-side, returning the patched result as a new message. Your application never has to implement diff parsing or patching logic.
The model produces a unified diff. The gateway detects the diff, locates the original code block in the conversation, applies the patch, and appends the patched file content as a subsequent assistant message part.
After the patch is applied, the assistant message includes a code block with the patched result:
The model can then reason about the patched code in subsequent turns.
| Option | Type | Default | Description |
|---|---|---|---|
strict | boolean | false | Fail the request if the patch does not apply cleanly |
context_lines | integer | 3 | Unified diff context line count when generating |
If the diff cannot be applied cleanly (mismatched context lines, the original block changed), the gateway returns the raw diff in the message and sets a patch_failed: true field on the response. When strict: true, the request returns a 400 error instead.
Apply Patch has no per-invocation fee. You pay only the token cost of the conversation and the diff content.