Skip to main content

Overview

The Apply API enables lightning-fast code editing at 10,500+ tokens/second with 98% accuracy. This OpenAI-compatible endpoint intelligently merges code changes while preserving structure and formatting.

Models

Choose the model that best fits your use case:

Message Format

The Apply API uses a structured XML format within the message content:

Format Guidelines

  • <instruction>: Optional but recommended. Use first-person, clear descriptions
  • <code>: The complete original code that needs modification
  • <update>: Show only what changes, using // ... existing code ... for unchanged sections

Usage Examples

Error Codes

edit_file Tool Guide

Build AI agent tools with Morph Apply

More Examples

See more implementation patterns