Skip to content
  • Models
  • Rankings
  • Ori
Sign Up
Sign Up
OpenRouterOpenRouter
© 2026 OpenRouter, Inc

Product

  • Chat
  • Rankings
  • Benchmarks
  • Apps
  • Discover
  • Models
  • Collections
  • Providers
  • Tools
  • Pricing
  • Business
  • Enterprise
  • Labs

Company

  • About
  • Blog
  • Careers
    Hiring
  • Privacy
  • Terms of Service
  • Trust Center
  • Support
  • Works With OR
  • Data
  • Brand

Developer

  • Documentation
  • API Reference
  • Developer Platform
  • Status

Connect

  • Discord
  • GitHub
  • LinkedIn
  • X
  • YouTube
All server tools

Apply patch

openrouter:apply_patch

Docs

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.

Docs

How it works

The building block for coding agents that edit files.

  1. 1

    Your model writes a V4A diff that creates, updates, or deletes a file.

  2. 2

    OpenRouter validates the diff, and returns invalid patches to the model to fix.

  3. 3

    Your app applies the patch to its own files and reports the result on the next turn.

Providers and pricing

  • Favicon for https://openrouter.ai

    OpenRouter validator

    Free

    OpenRouter validates the V4A diff and returns a structured apply_patch call.

  • Favicon for https://openai.com

    OpenAI

    Native
    Provider pricing

    Built-in apply_patch on GPT-5 and later.

    Via OpenAI, Azure

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.

shell
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 guide

Related tools

Code & execution

  • Shell

    A sandboxed hosted shell for any model

    Code & execution
  • Bash

    Anthropic-style bash tool with optional sandboxed execution

    Code & execution