Skip to main content
POST
Create a chat completion
🔒 CONFIDENTIAL - INTERNAL USE ONLYThis page contains proprietary enterprise API documentation and is linked to your account. Do not share any information mentioned here with anyone external to your company. This documentation is for internal development and integration purposes only.

Quickstart

Switch to instruction-guided editing with 98% accuracy in 3 steps.

Prerequisites

  • Enterprise API key from your Morph account
  • Access to https://api.morphllm.com/v1/

1. Configure Your Edit Tool

Set up your AI agent to generate the proper instructions guided format for the highest accuracy editing.
Edit File Tool Description:
Parameters:
  • target_filepath (string, required): The path of the target file to modify
  • instructions (string, required): A single sentence written in the first person describing what you’re changing. Used to help disambiguate uncertainty in the edit.
  • code_edit (string, required): Specify ONLY the precise lines of code that you wish to edit. Use // ... existing code ... for unchanged sections.
The instructions field should be generated by your AI model, not user input. Follow the tool description above nearly verbatim - terminology like “use it to disambiguate uncertainty in the edit” should be used. Example: “I am adding error handling to the user authentication function”

2. Send to Morph Enterprise API

3. Handle the Response

Extract the merged code from the enterprise API response. Response Format:
Extract the Final Code:

Enterprise Features

Perfect Accuracy

Instruction-guided editing achieves 98% accuracy on complex code changes

44k Input Tokens

Handle entire large files, complete modules, and complex codebases

36k Output Tokens

Generate complete implementations, full refactors, and comprehensive updates
Migration from Standard API:
Enterprise API requires an <instruction> field but maintains backward compatibility with existing <update> patterns.

Authorizations

Authorization
string
header
required

Morph API key, passed as Authorization: Bearer sk-.... Create keys at https://www.morphllm.com/dashboard/api-keys.

Body

application/json

Chat completion request for Apply or Warp Grep (OpenAI-compatible)

Either a Morph Apply request or a Warp Grep request, discriminated by model.

model
enum<string>
default:morph-v3-fast
required

ID of the Apply model to use, or auto to let the router choose

Available options:
morph-v3-fast,
morph-v3-large,
auto
Example:

"morph-v3-fast"

messages
object[]
required

Array containing a single user message with structured content using instruction-guided format

Example:
stream
boolean
default:false

Enable streaming response. When true the response is a text/event-stream of OpenAI-style chat.completion.chunk deltas terminated by data: [DONE].

Example:

false

max_tokens
integer

Maximum number of tokens the Apply model may generate

Example:

150

temperature
number
default:0

Sampling temperature for the Apply request (0.0 for deterministic output)

Example:

0

Response

Chat completion response

Completion returned by a Morph chat model.

id
string
required

Unique identifier for the completion

Example:

"chatcmpl-123"

object
string
required

Always chat.completion

Example:

"chat.completion"

created
integer
required

Unix timestamp of when the completion was created

Example:

1677652288

choices
object[]
required

List of completion choices

Example:
usage
object
required

Usage statistics for the completion request

Example: