Apply patch
openrouter:apply_patch
Lets coding agents edit files with structured patches. The model emits a V4A diff, OpenRouter validates it and returns a structured apply_patch call, and your application applies the change to its own files.
How it works
The building block for coding agents that edit files.
- 1
Your model writes a V4A diff that creates, updates, or deletes a file.
- 2
OpenRouter validates the diff, and returns invalid patches to the model to fix.
- 3
Your app applies the patch to its own files and reports the result on the next turn.
Providers and pricing
OpenRouter validator
Free
OpenRouter validates the V4A diff and returns a structured apply_patch call.
Standard model token costs apply to every request.
Using this tool
OpenRouter validates the diff and returns it as an apply_patch_call output item. Your application applies the patch to its own files and sends the result back as apply_patch_call_output on the next turn.
Available through the API. Patches are applied by your application, so there is no file system to edit in the chatroom.
Supported APIs: Responses.
curl https://openrouter.ai/api/v1/responses \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.2",
"tools": [
{
"type": "openrouter:apply_patch"
}
],
"input": "Rename the function greet to sayHello in src/index.ts."
}'Setup, parameters, and examples in the docs.
Read the integration guideFrequently asked questions
Related tools
Code & execution