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

# Create completion

> Generates a completion response for the provided model and prompt.



## OpenAPI

````yaml /openapi/serverless-openapi.yaml post /v1/completions
openapi: 3.0.0
info:
  title: Nscale Inference API
  version: 1.26.0
servers:
  - url: https://inference.api.nscale.com
    description: Production
security: []
tags:
  - name: Inference
  - name: Models
paths:
  /v1/completions:
    post:
      tags:
        - Inference
      summary: Create completion
      description: Generates a completion response for the provided model and prompt.
      requestBody:
        content:
          application/json; charset=utf-8:
            schema:
              $ref: '#/components/schemas/CompletionRequestBody'
        required: true
      responses:
        '200':
          description: ''
          content:
            application/json; charset=utf-8:
              schema:
                $ref: '#/components/schemas/CompletionResponseBody'
            text/event-stream:
              schema:
                type: array
                format: event-stream
                items:
                  $ref: '#/components/schemas/CompletionStreamedResponse'
          headers:
            INFERENCE-ID:
              required: true
              deprecated: false
              schema:
                type: string
        '400':
          description: ''
          content:
            application/json; charset=utf-8:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: ''
          content:
            application/json; charset=utf-8:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: ''
          content:
            application/json; charset=utf-8:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: ''
          content:
            application/json; charset=utf-8:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: ''
          content:
            application/json; charset=utf-8:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: ''
          content:
            application/json; charset=utf-8:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: ''
          content:
            application/json; charset=utf-8:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - IdentityAuthorization: []
components:
  schemas:
    CompletionRequestBody:
      type: object
      title: CompletionRequestBody
      required:
        - model
        - prompt
      properties:
        model:
          type: string
        prompt:
          $ref: '#/components/schemas/PromptValue'
        stream:
          type: boolean
          default: false
        stream_options:
          $ref: '#/components/schemas/StreamOptions'
        max_tokens:
          type: integer
          format: int32
        'n':
          type: integer
          format: int32
          default: 1
        frequency_penalty:
          type: number
          format: float
          default: 0
        logit_bias:
          type: object
          additionalProperties:
            type: number
            format: float
        logprobs:
          type: integer
          format: int32
          default: 0
        presence_penalty:
          type: number
          format: float
          default: 0
        stop:
          $ref: '#/components/schemas/StopSequence'
        temperature:
          type: number
          format: float
          default: 1
        top_p:
          type: number
          format: float
          default: 1
        echo:
          type: boolean
        suffix:
          type: string
        best_of:
          type: integer
          format: int32
        seed:
          type: integer
          format: int64
    CompletionResponseBody:
      type: object
      title: CompletionResponseBody
      required:
        - id
        - object
        - created
        - model
        - choices
        - usage
      properties:
        id:
          type: string
        object:
          type: string
        created:
          type: integer
          format: int64
        model:
          type: string
        choices:
          type: array
          items:
            $ref: '#/components/schemas/CompletionChoice'
        usage:
          $ref: '#/components/schemas/Usage'
        system_fingerprint:
          type: string
    CompletionStreamedResponse:
      type: object
      title: CompletionStreamedResponse
      required:
        - id
        - object
        - created
        - model
        - choices
      properties:
        id:
          type: string
        object:
          type: string
        created:
          type: integer
          format: int64
        model:
          type: string
        choices:
          type: array
          items:
            $ref: '#/components/schemas/CompletionStreamChoice'
        usage:
          $ref: '#/components/schemas/Usage'
        system_fingerprint:
          type: string
    ErrorResponse:
      type: object
      title: ErrorResponse
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ApiError'
    PromptValue:
      type: object
      anyOf:
        - type: string
        - type: array
          items:
            type: string
        - type: array
          items:
            type: integer
            format: int32
        - type: array
          items:
            type: array
            items:
              type: integer
              format: int32
    StreamOptions:
      type: object
      title: StreamOptions
      required:
        - include_usage
      properties:
        include_usage:
          type: boolean
    StopSequence:
      type: object
      anyOf:
        - type: string
        - type: array
          items:
            type: string
    CompletionChoice:
      type: object
      title: CompletionChoice
      required:
        - text
        - index
      properties:
        text:
          type: string
        index:
          type: integer
          format: int32
        logprobs:
          $ref: '#/components/schemas/LogProbs'
        finish_reason:
          type: string
    Usage:
      type: object
      title: Usage
      required:
        - prompt_tokens
        - total_tokens
        - completion_tokens
      properties:
        prompt_tokens:
          type: integer
          format: uint32
        total_tokens:
          type: integer
          format: uint32
        completion_tokens:
          type: integer
          format: uint32
        prompt_tokens_details: {}
    CompletionStreamChoice:
      type: object
      title: CompletionStreamChoice
      required:
        - index
        - text
      properties:
        index:
          type: integer
          format: int32
        text:
          type: string
        logprobs:
          $ref: '#/components/schemas/LogProbs'
        finish_reason:
          type: string
    ApiError:
      type: object
      title: ApiError
      required:
        - code
        - message
        - error_type
      properties:
        code:
          type: string
        message:
          type: string
        param:
          type: string
        error_type:
          type: string
    LogProbs:
      type: object
      title: LogProbs
      properties:
        tokens:
          type: array
          items:
            type: string
        token_logprobs:
          type: array
          items:
            type: number
            format: float
        top_logprobs:
          type: array
          items:
            type: object
            additionalProperties:
              type: number
              format: float
        text_offset:
          type: array
          items:
            type: integer
            format: int32
  securitySchemes:
    IdentityAuthorization:
      type: http
      description: Security scheme that accepts Unikorn Identity JWTs.
      scheme: bearer

````