Server tools are currently in beta. The API and behavior may change.
The apply patch server tool is only available through the Responses API. It is not supported via the Chat Completions API.
Only OpenAI models stream apply patch results incrementally via response.apply_patch_call_operation_diff.delta events. All other models return the complete patch as a single tool output.
The openrouter:apply_patch server tool enables models to propose file changes using V4A diff patches. This is the building block for coding agents — the model generates a patch describing file creates, updates, or deletes, OpenRouter validates the diff syntax, and your application applies it.
{ "type": "openrouter:apply_patch" } in your tools array when calling the Responses API.apply_patch_call output item — your application applies the patch to the filesystem and echoes the result back as apply_patch_call_output on the next turn.This is a human-in-the-loop tool: OpenRouter validates the diff but never applies it. Your application is responsible for executing the file operation.
The tool supports three operation types, each carried as the operation field on the apply_patch_call output item:
create_fileCreates a new file. Every content line in the diff must start with +:
update_fileUpdates an existing file using a V4A diff with context lines ( prefix), additions (+), and deletions (-):
delete_fileDeletes a file. No diff is needed — only the file path:
After your application applies (or rejects) the patch, send the result back on the next turn as an apply_patch_call_output input item:
The apply patch tool accepts an optional engine parameter:
response.apply_patch_call_operation_diff.delta events, matching OpenAI’s streaming format. Currently supported on OpenAI endpoints.apply_patch_call output item.The apply patch tool has no additional cost beyond standard token usage.