Skip to content

Apply Edit

Fresh

Generate code completions that intelligently merge updates into existing code while maintaining structure, order, comments, and indentation.

Endpoint

POST https://api.inceptionlabs.ai/v1/apply/completions

Request Format

The Mercury Edit model requires two sections in the message content:

  1. Original Code — Wrapped in <|original_code|> tags
  2. 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:

  1. Reads the original code block
  2. Identifies the update snippet with // ... existing code ... placeholders
  3. Intelligently merges updates while preserving existing structure
  4. Maintains indentation, comments, and code order

Parameters

ParameterTypeDescription
modelstringMust be "mercury-edit"
messagesarrayMessage with original code + update snippet
max_tokensintMax tokens to generate (1-8,192)

See Also