> ## 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 chat completion

> Generates a chat completion response for the provided model and chat history.



## OpenAPI

````yaml /openapi/serverless-openapi.yaml post /v1/chat/completions
openapi: 3.0.0
info:
  title: Nscale Inference API
  version: 1.26.0
servers:
  - url: https://aiproxy.infaas-amd-dev.glo1.nscale.com
security: []
tags:
  - name: Inference
  - name: Models
paths:
  /v1/chat/completions:
    post:
      tags:
        - Inference
      summary: Create chat completion
      description: >-
        Generates a chat completion response for the provided model and chat
        history.
      requestBody:
        content:
          application/json; charset=utf-8:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequestBody'
        required: true
      responses:
        '200':
          description: ''
          content:
            application/json; charset=utf-8:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponseBody'
            text/event-stream:
              schema:
                type: array
                format: event-stream
                items:
                  $ref: '#/components/schemas/ChatCompletionStreamedResponse'
          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:
    ChatCompletionRequestBody:
      type: object
      title: ChatCompletionRequestBody
      required:
        - model
        - messages
      properties:
        model:
          type: string
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ChatCompletionMessageType'
        stream:
          type: boolean
          default: false
        stream_options:
          $ref: '#/components/schemas/StreamOptions'
        max_completion_tokens:
          type: integer
          format: int32
        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: boolean
          default: false
        presence_penalty:
          type: number
          format: float
          default: 0
        response_format:
          $ref: '#/components/schemas/ResponseFormat'
        stop:
          $ref: '#/components/schemas/StopSequence'
        temperature:
          type: number
          format: float
          default: 1
        top_p:
          type: number
          format: float
          default: 1
        top_logprobs:
          type: integer
          format: int32
        tool_choice:
          description: >-
            Controls which (if any) tool is called by the model. Only 'auto' and
            'none' are supported here.

            'required' tool_choice option requires vllm>=0.8.3 and is not
            currently supported.
        tools:
          type: array
          items: {}
        seed:
          type: integer
          format: int64
        reasoning_effort:
          type: string
      example:
        frequency_penalty: 0
        logit_bias: null
        logprobs: false
        max_completion_tokens: 100
        max_tokens: 100
        messages:
          - content: What is the weather in Paris?
            role: user
        model: meta-llama/Llama-3.1-8B-Instruct
        'n': 1
        presence_penalty: 0
        reasoning_effort: medium
        seed: 42
        stop: |+

        stream: false
        stream_options: null
        temperature: 1
        tool_choice: auto
        tools:
          - function:
              description: Get the weather for a city
              name: get_weather
              parameters:
                properties:
                  city:
                    description: City name
                    type: string
                required:
                  - city
                type: object
            type: function
        top_logprobs: 0
        top_p: 1
    ChatCompletionResponseBody:
      type: object
      title: ChatCompletionResponseBody
      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/ChatCompletionChoice'
        usage:
          $ref: '#/components/schemas/Usage'
        prompt_logprobs:
          type: string
        system_fingerprint:
          type: string
    ChatCompletionStreamedResponse:
      type: object
      title: ChatCompletionStreamedResponse
      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/ChatCompletionStreamChoice'
        usage:
          $ref: '#/components/schemas/Usage'
        system_fingerprint:
          type: string
    ErrorResponse:
      type: object
      title: ErrorResponse
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ApiError'
    ChatCompletionMessageType:
      type: object
      anyOf:
        - $ref: '#/components/schemas/Message'
        - $ref: '#/components/schemas/ImageMessage'
    StreamOptions:
      type: object
      title: StreamOptions
      required:
        - include_usage
      properties:
        include_usage:
          type: boolean
    ResponseFormat:
      type: object
      title: ResponseFormat
      required:
        - type
      properties:
        type:
          type: string
        json_schema:
          $ref: '#/components/schemas/JsonSchemaResponseFormat'
    StopSequence:
      type: object
      anyOf:
        - type: string
        - type: array
          items:
            type: string
    ChatCompletionChoice:
      type: object
      title: ChatCompletionChoice
      required:
        - index
        - message
      properties:
        index:
          type: integer
          format: int32
        message:
          $ref: '#/components/schemas/Message'
        logprobs:
          $ref: '#/components/schemas/MessageLogprobs'
        finish_reason:
          type: string
        stop_reason: {}
    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: {}
    ChatCompletionStreamChoice:
      type: object
      title: ChatCompletionStreamChoice
      required:
        - index
        - delta
      properties:
        index:
          type: integer
          format: int32
        delta:
          $ref: '#/components/schemas/Delta'
        logprobs:
          $ref: '#/components/schemas/MessageLogprobs'
        finish_reason:
          type: string
        stop_reason: {}
    ApiError:
      type: object
      title: ApiError
      required:
        - code
        - message
        - error_type
      properties:
        code:
          type: string
        message:
          type: string
        param:
          type: string
        error_type:
          type: string
    Message:
      type: object
      title: Message
      required:
        - role
      properties:
        role:
          type: string
        content:
          type: string
        reasoning_content:
          type: string
        tool_calls:
          type: array
          items: {}
    ImageMessage:
      type: object
      title: ImageMessage
      required:
        - role
        - content
      properties:
        role:
          type: string
        content:
          type: array
          items:
            $ref: '#/components/schemas/MessageContent'
    JsonSchemaResponseFormat:
      type: object
      title: JsonSchemaResponseFormat
      required:
        - name
      properties:
        name:
          type: string
        description:
          type: string
        schema: {}
        strict:
          type: boolean
    MessageLogprobs:
      type: object
      title: MessageLogprobs
      required:
        - content
      properties:
        content:
          type: array
          items:
            $ref: '#/components/schemas/LogprobToken'
    Delta:
      type: object
      title: Delta
      properties:
        role:
          type: string
        content:
          type: string
        reasoning_content:
          type: string
        tool_calls: {}
    MessageContent:
      type: object
      anyOf:
        - $ref: '#/components/schemas/MessageContent_ImageUrl'
        - $ref: '#/components/schemas/MessageContent_Text'
      discriminator:
        propertyName: type
        mapping:
          image_url:
            $ref: '#/components/schemas/MessageContent_ImageUrl'
          text:
            $ref: '#/components/schemas/MessageContent_Text'
    LogprobToken:
      type: object
      title: LogprobToken
      required:
        - token
        - logprob
      properties:
        token:
          type: string
        logprob:
          type: number
          format: float
        bytes:
          type: array
          items:
            type: integer
            format: int32
        top_logprobs:
          type: array
          items:
            $ref: '#/components/schemas/NestedLogprobToken'
    MessageContent_ImageUrl:
      allOf:
        - type: object
          required:
            - type
          properties:
            type:
              type: string
              enum:
                - image_url
              example: image_url
        - $ref: '#/components/schemas/ImageUrl'
    MessageContent_Text:
      allOf:
        - type: object
          required:
            - type
          properties:
            type:
              type: string
              enum:
                - text
              example: text
        - $ref: '#/components/schemas/Text'
    NestedLogprobToken:
      type: object
      title: NestedLogprobToken
      required:
        - token
        - logprob
      properties:
        token:
          type: string
        logprob:
          type: number
          format: float
        bytes:
          type: array
          items:
            type: integer
            format: int32
    ImageUrl:
      type: object
      title: ImageUrl
      required:
        - type
        - image_url
      properties:
        type:
          type: string
        image_url:
          $ref: '#/components/schemas/Url'
    Text:
      type: object
      title: Text
      required:
        - type
        - text
      properties:
        type:
          type: string
        text:
          type: string
    Url:
      type: object
      title: Url
      required:
        - url
      properties:
        url:
          type: string
  securitySchemes:
    IdentityAuthorization:
      type: http
      description: Security scheme that accepts Unikorn Identity JWTs.
      scheme: bearer

````