> ## Documentation Index
> Fetch the complete documentation index at: https://docs.webless.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Get completions

> Returns prefix-guaranteed inline autocomplete completions for query inputs. Use this for ghost text while a user is typing. Every returned `text` starts with the requested `prefix` case-insensitively.

<Note>
  Use this endpoint for inline query autocomplete while a user is typing. It is
  separate from [`suggestions`](/api-reference/latest/search/suggestions), which
  returns follow-up prompts after a query is submitted.
</Note>

Call the endpoint after a short delay when the user stops typing, using the current
`prefix`. Abort in-flight requests when the prefix changes. Use the returned
`suffix` to render ghost text after the user's typed text.

Pass `previous_completions` when you want to avoid repeating completions already
shown to the user. When `is_private_session` is `true`, the API returns an empty
completion set.


## OpenAPI

````yaml api-reference/openapi-latest.json POST /api/v1/completions
openapi: 3.1.0
info:
  title: Webless API
  description: >-
    Reference for the latest Webless API surface. New integrations should use
    the /api/v1 endpoints.
  version: v1
servers:
  - url: https://api.webless.ai
    description: Production Search API
security: []
paths:
  /api/v1/completions:
    post:
      tags:
        - Search API
      summary: Get completions
      description: >-
        Returns prefix-guaranteed inline autocomplete completions for query
        inputs. Use this for ghost text while a user is typing. Every returned
        `text` starts with the requested `prefix` case-insensitively.
      operationId: getCompletionsV1
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/V1CompletionsRequest'
            examples:
              default:
                value:
                  prefix: How is
                  company: YOUR_COMPANY
                  requestId: 1f7c5f74-7b9e-4a0a-9b7d-4e3e2a5e3b60
                  sessionId: a1c2d3e4-1111-2222-3333-444455556666
                  'n': 5
                  previous_completions:
                    - How is pricing structured?
                  version: published
      responses:
        '200':
          description: Inline autocomplete completions for the supplied prefix
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/V1CompletionsResponse'
              examples:
                default:
                  value:
                    prefix: How is
                    completions:
                      - text: How is pricing structured?
                        suffix: ' pricing structured?'
                        score: 0.91
                    best:
                      text: How is pricing structured?
                      suffix: ' pricing structured?'
                      score: 0.91
                empty:
                  value:
                    prefix: How is
                    completions: []
                    best: null
        '422':
          description: Invalid request body
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationErrorResponse'
components:
  schemas:
    V1CompletionsRequest:
      type: object
      required:
        - prefix
        - sessionId
      properties:
        prefix:
          type: string
          description: >-
            User-typed prefix. Internal whitespace runs are normalized
            server-side.
          example: How is
        sessionId:
          type: string
          example: a1c2d3e4-1111-2222-3333-444455556666
        company:
          type: string
          default: sigma
          example: YOUR_COMPANY
        version:
          $ref: '#/components/schemas/V1RuntimeVersion'
        'n':
          type: integer
          default: 5
          minimum: 0
          maximum: 10
          description: Maximum number of completions to return. Capped at 10.
          example: 5
        previous_completions:
          type: array
          items:
            type: string
          nullable: true
          description: Exact completions to exclude from results.
          example:
            - How is pricing structured?
        requestId:
          type: string
          example: 1f7c5f74-7b9e-4a0a-9b7d-4e3e2a5e3b60
        is_private_session:
          type: boolean
          default: false
          description: When true, returns an empty completion set.
    V1CompletionsResponse:
      type: object
      required:
        - prefix
        - completions
        - best
      properties:
        prefix:
          type: string
          description: Normalized prefix echoed from the request.
        completions:
          type: array
          items:
            $ref: '#/components/schemas/V1CompletionItem'
          description: Ranked completion candidates. Empty when no matches are available.
        best:
          allOf:
            - $ref: '#/components/schemas/V1CompletionItem'
          nullable: true
          description: Top-ranked completion, if any.
    ValidationErrorResponse:
      type: object
      properties:
        detail:
          type: array
          items:
            type: object
            additionalProperties: true
    V1RuntimeVersion:
      type: string
      enum:
        - published
        - unpublished
      default: published
      description: >-
        Runtime package pointer. Omit this field or use `published` for
        production traffic. Use `unpublished` only when testing an unpublished
        runtime package.
    V1CompletionItem:
      type: object
      required:
        - text
        - suffix
      properties:
        text:
          type: string
          description: >-
            Full completion text. Always starts with the requested prefix
            case-insensitively.
        suffix:
          type: string
          description: >-
            Remaining text after the user-typed prefix. Use this for ghost text
            in the input.
        score:
          type: number
          nullable: true
          description: Optional relevance score for ranking.

````