Endpoints
Apply Code Updates
Apply code updates to an original file using Morph Apply. Find your API key in the Morph Dashboard.
POST
Overview
Morph uses a standard OpenAI-compatible API. You’ll use the Chat Completions endpoint with a specific formatting for your code and updates.
API Endpoint
Example Request
Input Format
The content
field in your message should contain two parts:
- Original code wrapped in
<code>...</code>
tags - Update snippet wrapped in
<update>...</update>
tags
The update snippet should use truncation markers like // ... existing code ...
to indicate unchanged parts of the code. Your system prompt should include instructions on how to handle these markers.
Read more about how to handle prompting here.
Example with Python
Response Format
Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Body
application/json
Code update request
The body is of type object
.
Response
200
application/json
Chat completion response
The response is of type object
.