Apply Edit
FreshGenerate code completions that intelligently merge updates into existing code while maintaining structure, order, comments, and indentation.
Endpoint
POST https://api.inceptionlabs.ai/v1/apply/completionsRequest Format
The Mercury Edit model requires two sections in the message content:
- Original Code — Wrapped in
<|original_code|>tags - Update Snippet — Wrapped in
<|update_snippet|>tags with// ... existing code ...placeholders
bash
curl https://api.inceptionlabs.ai/v1/apply/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $INCEPTION_API_KEY" \
-d '{
"model": "mercury-edit",
"messages": [
{
"role": "user",
"content": "<|original_code|>\nclass Calculator {\n add(a, b) {\n return a + b;\n }\n subtract(a, b) {\n return a - b;\n }\n}\n<|original_code|>\n\n<|update_snippet|>\nclass Calculator {\n // ... existing code ...\n multiply(a, b) {\n return a * b;\n }\n}\n<|update_snippet|>"
}
],
"max_tokens": 2000
}'How It Works
The model:
- Reads the original code block
- Identifies the update snippet with
// ... existing code ...placeholders - Intelligently merges updates while preserving existing structure
- Maintains indentation, comments, and code order
Parameters
| Parameter | Type | Description |
|---|---|---|
model | string | Must be "mercury-edit" |
messages | array | Message with original code + update snippet |
max_tokens | int | Max tokens to generate (1-8,192) |
See Also
- Next Edit — Predictive edit suggestions
- Autocomplete (FIM) — Fill-in-the-middle completions