Skip to main content
All endpoints accept and return JSON. Streaming endpoints use Server-Sent Events (SSE).

POST /completion

Stream an inline code completion. This is the main endpoint for editor integrations.

Request body

{
  "prefix": "function add(a: number, b: number) {\n  ",
  "suffix": "\n}",
  "language": "typescript",
  "filename": "/absolute/path/to/file.ts",
  "project_root": "/absolute/path/to/project",
  "model": "claude-haiku-4-5-20251001",
  "provider": "claude",
  "max_tokens": 256
}
FieldRequiredDescription
prefixyesCode before the cursor
suffixyesCode after the cursor
languagenoProgramming language (default: "typescript")
filenamenoAbsolute file path — enables import resolution and symbol lookup
project_rootnoProject root directory — enables convention analysis, sibling patterns, and project-scoped memory
modelnoModel ID (default: claude-haiku-4-5-20251001 for Claude, o4-mini for Codex)
providerno"claude" or "codex" (default: auto-detect)
max_tokensnoMax completion length
When project_root is provided, the server automatically:
  1. Analyzes conventions — formatting, naming, imports, error handling (cached 5 min)
  2. Resolves imports — reads exported APIs from imported files
  3. Finds sibling patterns — extracts structure from neighboring files
  4. Looks up symbols — greps for type/interface definitions referenced near the cursor
  5. Queries learned rules — fetches patterns you’ve reinforced through past accepts/rejects
All of this is injected into the prompt before the LLM sees your code.

Response

SSE stream with data: lines containing JSON:
data: {"type":"delta","text":"return a + b"}
data: {"type":"done"}
Event types:
TypeFieldsDescription
deltatextA chunk of completion text
doneStream complete
errorerrorError message

POST /completion/text

Stream general-purpose text generation (used by git commit, custom prompts).
{
  "prompt": "Explain this function...",
  "system": "You are a helpful assistant.",
  "model": "claude-haiku-4-5-20251001",
  "provider": "claude"
}
Response format is identical to /completion.

POST /completion/accept

Report that the user accepted a completion. Used for learning.
{
  "language": "typescript",
  "filename": "src/server.ts",
  "prefix": "const result = ",
  "accepted": "await db.query(sql, params)",
  "project_root": "/path/to/project"
}
The server:
  • Stores the entry in project-scoped memory
  • Auto-detects the completion category (import, error-handling, variable, etc.)
  • Re-runs rule extraction to look for emerging patterns

POST /completion/reject

Report that the user dismissed a completion.
{
  "language": "typescript",
  "prefix": "const result = ",
  "suggested": "null",
  "project_root": "/path/to/project"
}
Rejects reduce confidence in matching learned rules.

GET /completion/memory/stats

Returns memory statistics. Add ?project_root=/path/to/project for project-scoped stats.
{
  "total_accepts": 42,
  "total_rejects": 8,
  "learned_rules": 5,
  "acceptance_rate": 0.84,
  "by_language": { "typescript": 38, "python": 4 },
  "by_category": {
    "variable": { "accepts": 15, "rejects": 3 },
    "error-handling": { "accepts": 8, "rejects": 1 },
    "import": { "accepts": 12, "rejects": 2 }
  },
  "top_rules": [
    { "pattern": "const <var> = await <fn>()", "category": "variable", "confidence": 0.75, "examples": 8 },
    { "pattern": "throw new <ErrorType>(<message>)", "category": "error-handling", "confidence": 0.6, "examples": 5 }
  ]
}

DELETE /completion/memory

Clear all stored completions and learned rules. Add ?project_root=/path/to/project to clear only that project.

POST /completion/conventions

Trigger convention analysis for a project. Returns the detected conventions.
{
  "project_root": "/path/to/project",
  "language": "typescript"
}
Response:
{
  "language": "typescript",
  "formatting": { "semicolons": "never", "quotes": "double", "indentation": "2-spaces", "trailingCommas": true },
  "imports": { "aliasPrefix": "@/", "typeImports": true, "groupedImports": true },
  "naming": { "functions": "camelCase", "variables": "camelCase", "types": "PascalCase", "files": "kebab-case" },
  "errorHandling": { "style": "throw", "customErrorClass": "NamedError" },
  "patterns": ["Uses TypeScript namespaces for module organization", "Strongly prefers async/await over .then()"]
}

DELETE /completion/conventions

Invalidate the convention cache. Add ?project_root=/path/to/project to invalidate only that project.