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
Example Message Structure
Error Codes
edit_file Tool Guide
Build AI agent tools with Morph Apply
More Examples
See more implementation patterns
Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Body
application/json
Code update request
ID of the model to use
Available options:
morph-v3-fast
, morph-v3-large
, auto
Example:
"morph-v3-large"
Array containing a single user message with structured content using instruction-guided format
Enable streaming response
Example:
false
Response
Chat completion response
Unique identifier for the completion
Example:
"chatcmpl-123"
Object type
Example:
"chat.completion"
Unix timestamp of when the completion was created
Example:
1677652288
List of completion choices
Usage statistics for the completion request