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

# Get a Chat Completion



## OpenAPI

````yaml https://sudoapp.dev/api/openapi.json get /v1/chat/completions/{completion_id}
openapi: 3.1.0
info:
  title: sudo-api
  description: ''
  license:
    name: ''
  version: 0.1.0
servers: []
security:
  - api_key: []
  - privy_token: []
tags:
  - name: Sudo API
    description: 'Sudo: The Unified AI Developer Platform'
paths:
  /v1/chat/completions/{completion_id}:
    get:
      tags:
        - Router
      summary: Get a Chat Completion
      operationId: get_chat_completion
      parameters:
        - name: completion_id
          in: path
          description: ID of the chat completion
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Chat completion gotten successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletion'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: Bad gateway error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - api_key: []
components:
  schemas:
    ChatCompletion:
      type: object
      description: >-
        Represents a chat completion response returned by model, based on the
        provided input.
      required:
        - choices
        - created
        - id
        - model
        - object
        - usage
      properties:
        choices:
          type: array
          items:
            $ref: '#/components/schemas/Choice'
          description: >-
            A list of chat completion choices. Can be more than one if `n` is
            greater than 1.
        created:
          type: integer
          format: int64
          description: >-
            The Unix timestamp (in seconds) of when the chat completion was
            created.
          minimum: 0
        id:
          type: string
          description: A unique identifier for the chat completion.
        model:
          type: string
          description: The model used for the chat completion.
        object:
          type: string
          description: The object type, which is always `chat.completion`.
        service_tier:
          type:
            - string
            - 'null'
          description: >-
            The service tier used for processing the request. This field is only
            included if the `service_tier` parameter is specified in the
            request.
        system_fingerprint:
          type:
            - string
            - 'null'
          description: >-
            This fingerprint represents the backend configuration that the model
            runs with. Can be used in conjunction with the `seed` request
            parameter to understand when backend changes have been made that
            might impact determinism.
        usage:
          $ref: '#/components/schemas/Usage'
          description: Usage statistics for the completion request.
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
    Choice:
      type: object
      description: A chat completion choice.
      required:
        - finish_reason
        - index
        - message
      properties:
        finish_reason:
          type: string
          description: >-
            The reason the model stopped generating tokens. This will be `stop`
            if the model hit a natural stop point or a provided stop sequence,
            `length` if the maximum number of tokens specified in the request
            was reached, `content_filter` if content was omitted due to a flag
            from our content filters, or `tool_calls` if the model called a
            tool.
        index:
          type: integer
          format: int32
          description: The index of the choice in the list of choices.
          minimum: 0
        logprobs:
          description: Log probability information for the choice.
        message:
          $ref: '#/components/schemas/MessageResponse'
          description: A chat completion message generated by the model.
    Usage:
      type: object
      description: Usage statistics for the completion request.
      required:
        - completion_tokens
        - prompt_tokens
        - total_tokens
      properties:
        completion_tokens:
          type: integer
          format: int32
          description: Number of tokens in the generated completion.
          minimum: 0
        completion_tokens_details:
          description: >-
            Breakdown of tokens used in a completion. Not supported, we will
            always set to Null
        prompt_tokens:
          type: integer
          format: int32
          description: Number of tokens in the prompt.
          minimum: 0
        prompt_tokens_details:
          description: >-
            Breakdown of tokens used in the prompt. Not supported, we will
            always set to Null
        total_tokens:
          type: integer
          format: int32
          description: Total number of tokens used in the request (prompt + completion).
          minimum: 0
    ErrorDetail:
      type: object
      required:
        - message
        - type
      properties:
        message:
          type: string
        type:
          type: string
    MessageResponse:
      type: object
      description: A chat completion message generated by the model.
      required:
        - role
      properties:
        annotations:
          description: A list of annotations for the message content.
        audio:
          description: >-
            If the audio output modality is requested, this object contains data
            about the audio response from the model.
        content:
          type:
            - string
            - 'null'
          description: The contents of the message.
        refusal:
          type:
            - string
            - 'null'
          description: The refusal message generated by the model.
        role:
          type: string
          description: The role of the author of this message.
        tool_calls:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/ToolCall'
          description: The tool calls generated by the model, such as function calls.
    ToolCall:
      type: object
      description: A tool call generated by the model.
      required:
        - id
        - type
        - function
      properties:
        function:
          $ref: '#/components/schemas/ToolCallFunction'
          description: The function that the model called.
        id:
          type: string
          description: The ID of the tool call.
        type:
          type: string
          description: The type of the tool. Currently, only `function` is supported.
    ToolCallFunction:
      type: object
      description: The function that was called by the model.
      required:
        - name
        - arguments
      properties:
        arguments:
          type: string
          description: >-
            The arguments to call the function with, as generated by the model
            in JSON format. Note that the model does not always generate valid
            JSON, and may hallucinate parameters not defined by your function
            schema. Validate the arguments in your code before calling your
            function.
        name:
          type: string
          description: The name of the function to call.

````