Your agent outputs a lazy edit snippet (changed lines + // ... existing code ... markers). Morph merges it into the original file and returns the result. 98% accuracy, sub-second latency.
The instructions parameter must be generated by the model, not hardcoded. It provides context for ambiguous edits. Example: “Adding error handling to the user auth and removing the old auth functions.”
3
Add to your agent
The SDK provides tool factories for every major framework. One line gives your agent an edit_file tool:
Anthropic
OpenAI
Vercel AI SDK
import Anthropic from '@anthropic-ai/sdk';import { MorphClient } from '@morphllm/morphsdk';const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });const anthropic = new Anthropic();const response = await anthropic.messages.create({ model: "claude-sonnet-4-5-20250929", max_tokens: 12000, tools: [morph.anthropic.createEditFileTool()], messages: [{ role: "user", content: "Add error handling to src/auth.ts" }]});
import OpenAI from 'openai';import { MorphClient } from '@morphllm/morphsdk';const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });const openai = new OpenAI();const response = await openai.chat.completions.create({ model: "gpt-5-high", tools: [morph.openai.createEditFileTool()], messages: [{ role: "user", content: "Add error handling to src/auth.ts" }]});
import { generateText, stepCountIs } from 'ai';import { anthropic } from '@ai-sdk/anthropic';import { MorphClient } from '@morphllm/morphsdk';const morph = new MorphClient({ apiKey: process.env.MORPH_API_KEY });const result = await generateText({ model: anthropic('claude-sonnet-4-5-20250929'), tools: { editFile: morph.vercel.createEditFileTool() }, prompt: "Add error handling to src/auth.ts", stopWhen: stepCountIs(5)});
For tool definition schemas, system prompt instructions, and output-parsing mode, see the Fast Apply product page.
Code search subagent. Searches your codebase in its own context window, finds relevant code in 3.8 steps, returns file/line-range spans. Your agent’s context stays clean.