Next Edit
FreshGenerate predictive code edit suggestions based on context: recently viewed files, current cursor position, and edit history.
Endpoint
POST https://api.inceptionlabs.ai/v1/edit/completionsRequest Structure
The request content must include three sections:
1. Recently Viewed Snippets
Context from code the developer recently looked at. Include 3-5 snippets of roughly 20 lines each.
2. Current File Content
The file being edited, with the editable region marked using <|code_to_edit|> tags. Recommended: 10-15 lines (~100-150 tokens).
3. Edit Diff History
Recent changes in unidiff format. Include the last 3-5 edits, ordered chronologically (most recent last).
Example Request
bash
curl https://api.inceptionlabs.ai/v1/edit/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $INCEPTION_API_KEY" \
-d '{
"model": "mercury-edit",
"messages": [
{
"role": "user",
"content": "Recently Viewed Snippets:\n...\n\nCurrent File: src/utils.js\n<|code_to_edit|>\nfunction processData(input) {\n // TODO: implement\n}\n<|code_to_edit|>\n\nEdit History:\n..."
}
],
"max_tokens": 1000
}'Best Practices
| Component | Recommendation |
|---|---|
| Viewed Snippets | 3-5 snippets, ~20 lines each, centered on cursor positions |
| Edit Region | 10-15 lines (100-150 tokens), max ~25 lines |
| Region Selection | Center around cursor: [currentLine - 5, currentLine + 10] |
| Edit History | Last 3-5 user edits in unidiff format, most recent last |
| Broader Suggestions | Use parallel requests with different editable regions |
TIP
For broader edit suggestions, send parallel requests with different editable regions, or use linter-guided region selection.
See Also
- Apply Edit — Merge code updates
- Autocomplete (FIM) — Fill-in-the-middle
- Zed Integration — Next Edit in Zed editor