What is Fast Apply?

The Apply Model intelligently merges your original code with update snippets at 98% accuracy and 4500+ tokens/second. Unlike diff-based methods, it preserves code structure, comments, and syntax while understanding context semantically. Cursor uses Fast Apply to great success as detailed in their blog post.

Try the API Playground

Test the Apply Model instantly with live examples

Why Choose Fast Apply?

  • Ultra-fast: 4,500+ tokens/sec
  • High accuracy: 98% success rate in one pass
  • Token efficient: Processes only changed sections

Models

ModelSpeedAccuracyBest For
morph-v3-fast4500+ tok/sec96%Real-time edits
morph-v3-large2500+ tok/sec98%Production systems
autoVariable~98%Automatic selection

Quick Start

1

Setup Client

Python
from openai import OpenAI

client = OpenAI(
    api_key="your-morph-api-key",
    base_url="https://api.morphllm.com/v1"
)
2

Apply Changes

Python
def apply_edit(instruction: str, original: str, update: str):
    response = client.chat.completions.create(
        model="morph-v3-large",
        messages=[{
            "role": "user",
            "content": f"<instruction>{instruction}</instruction>\n<code>{original}</code>\n<update>{update}</update>"
        }]
    )
    return response.choices[0].message.content

# Example
original = """
const authenticateUser = () => {
  return "Authenticated"
}
"""
# These should be coming from your Agent
instruction = "I will add async authentication with parameters"
update = """
const authenticateUser = async (email, password) => {
  const result = await verifyUser(email, password)
  return result ? "Authenticated" : "Unauthenticated"
}
"""

final_code = apply_edit(instruction, original, update)

Best Practices

Update Snippets: Use // ... existing code ... for unchanged sections:
// Good
const authenticateUser = async (email, password) => {
  // ... existing code ...
  const result = await verifyUser(email, password)
  return result ? "Authenticated" : "Unauthenticated"
}
Instructions: Have the agent write clear, first-person descriptions: prompt it to “use it to disambiguate uncertianty in the edit”
  • ✅ “I will add async/await error handling”
  • ❌ “Change this function”

Next Steps