---
title: "Autocomplete"
method: POST
path: "/v1/chat/autocomplete"
tags: ["chat", "llm"]
---

# Autocomplete

`POST /v1/chat/autocomplete`

## Request body

- AutocompleteRequest
  - `context` AutocompleteContext
    - `document` DocumentContext, required
      - `filename` string, required — File name
      - `languageId` string, required — Programming language ID
      - `prefix` union, required — Code before cursor (string or array of content parts)
        - string
        - ContentPart[]
          - `type` string, required — Content type (text, image_url, etc.)
          - `text` string, nullable — Text content
          - `image_url` object, nullable — Image URL object
      - `suffix` union, required — Code after cursor (string or array of content parts)
        - string
        - ContentPart[]
          - `type` string, required — Content type (text, image_url, etc.)
          - `text` string, nullable — Text content
          - `image_url` object, nullable — Image URL object
      - `position` Position, required
        - `line` integer, required — Line number
        - `character` integer, required — Character position
        - `offset` integer, required — Offset from start
      - `boundaries` Boundaries
        - `prefixStartsAtBeginning` boolean, nullable — Whether prefix starts at document beginning
        - `suffixEndsAtEnd` boolean, nullable — Whether suffix ends at document end
        - `prefixTokens` integer, nullable — Estimated prefix tokens
        - `suffixTokens` integer, nullable — Estimated suffix tokens
      - `editorConfig` EditorConfig
        - `indentationSize` integer, nullable — Indentation size
        - `indentationChar` string, nullable — Indentation character (space/tab)
        - `currentLineIndentation` integer, nullable — Current line indentation level
        - `isEmptyLine` boolean, nullable — Whether current line is empty
    - `relatedFiles` RelatedFile[], nullable — Related files
      - `path` string, nullable — Absolute file path
      - `relativePath` string, nullable — Relative file path
      - `content` union — File content (string or array of content parts)
        - string
        - ContentPart[]
          - `type` string, required — Content type (text, image_url, etc.)
          - `text` string, nullable — Text content
          - `image_url` object, nullable — Image URL object
      - `score` number, nullable — Relevance score (0-1)
      - `languageId` string, nullable — Programming language ID
    - `imports` ImportStatement[], nullable — Import statements
      - `text` union — Full import statement text (string or array)
        - string
        - ContentPart[]
          - `type` string, required — Content type (text, image_url, etc.)
          - `text` string, nullable — Text content
          - `image_url` object, nullable — Image URL object
      - `module` string, nullable — Module name
      - `symbols` string[], nullable — Imported symbols
    - `nearbyDefinitions` CodeDefinition[], nullable — Nearby code definitions
      - `name` string, nullable — Definition name
      - `type` string, nullable — Definition type (function/class/variable)
      - `text` union — Definition text (string or array)
        - string
        - ContentPart[]
          - `type` string, required — Content type (text, image_url, etc.)
          - `text` string, nullable — Text content
          - `image_url` object, nullable — Image URL object
      - `distanceFromCursor` integer, nullable — Distance from cursor in lines
    - `recentEdits` RecentEdit[], nullable — Recent edits
      - `timestamp` integer, nullable — Edit timestamp
      - `text` union — Edited text (string or array)
        - string
        - ContentPart[]
          - `type` string, required — Content type (text, image_url, etc.)
          - `text` string, nullable — Text content
          - `image_url` object, nullable — Image URL object
      - `line` integer, nullable — Line number
    - `tokenBudget` TokenBudget
      - `total` integer, nullable — Total token budget
      - `prefix` integer, nullable — Prefix token budget
      - `suffix` integer, nullable — Suffix token budget
      - `relatedFiles` integer, nullable — Related files token budget
      - `recentEdits` integer, nullable — Recent edits token budget
    - `metadata` ContextMetadata
      - `version` string, nullable — Context format version
      - `vscodeVersion` string, nullable — VSCode version
      - `timestamp` integer, nullable — Request timestamp
      - `requestId` string, nullable — Unique request ID
  - `prompt` string, nullable — FIM prompt/prefix for Copilot-style autocomplete
  - `suffix` string, nullable — FIM suffix for Copilot-style autocomplete
  - `n` integer, nullable — Number of completion choices to request
  - `stop` union — Stop sequence or sequences
    - string
    - string[]
  - `stream` boolean, nullable — Whether to stream Copilot-style completion chunks
  - `top_p` number, nullable — Top-p sampling value
  - `extra` AutocompleteExtra
    - `language` string, nullable — Programming language
    - `next_indent` integer, nullable — Next-line indentation columns
    - `trim_by_indentation` boolean, nullable — Trim completion by indentation
    - `prompt_tokens` integer, nullable — Estimated prompt tokens
    - `suffix_tokens` integer, nullable — Estimated suffix tokens
    - `context` string[], nullable — Pre-built context strings
  - `code_annotations` boolean, nullable — Whether code annotations are requested
  - `filename` string, nullable — File name
  - `before` union — Code before cursor (string or array)
    - string
    - ContentPart[]
      - `type` string, required — Content type (text, image_url, etc.)
      - `text` string, nullable — Text content
      - `image_url` object, nullable — Image URL object
  - `after` union — Code after cursor (string or array)
    - string
    - ContentPart[]
      - `type` string, required — Content type (text, image_url, etc.)
      - `text` string, nullable — Text content
      - `image_url` object, nullable — Image URL object
  - `line` integer, nullable — Line number
  - `character` integer, nullable — Character position
  - `offset` integer, nullable — Offset from start
  - `beforeLength` integer, nullable — Length of before text
  - `afterLength` integer, nullable — Length of after text
  - `region_includes_beginning` boolean, nullable — Whether region includes beginning
  - `region_includes_end` boolean, nullable — Whether region includes end
  - `max_num_results` integer, nullable — Maximum number of results
  - `maxResults` integer, nullable — Maximum number of results (alternative)
  - `indentation_size` integer, nullable — Indentation size
  - `model` string, nullable — Internal model ID to use
  - `max_tokens` integer, nullable — Max tokens to generate
  - `temperature` number, nullable — Temperature

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/kodik/apis/kodik-api.md) · [All operations](https://skmtc.dev/kodik/apis/kodik-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/kodik/kodik-api/revisions/55c71b347360/schema)
