> ## 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.

# Create Chat Completion



## OpenAPI

````yaml https://sudoapp.dev/api/openapi.json post /v1/chat/completions
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:
    post:
      tags:
        - Router
      summary: Create Chat Completion
      operationId: create_chat_completion
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
        required: true
      responses:
        '200':
          description: Chat completion created 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:
    ChatCompletionRequest:
      type: object
      required:
        - messages
        - model
      properties:
        audio:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/AudioParameters'
              description: >-
                Parameters for audio output. Required when audio output is
                requested with modalities: ["audio"]. Input audio is
                automatically detected.
        frequency_penalty:
          type:
            - number
            - 'null'
          format: float
          description: >-
            Number between -2.0 and 2.0. Positive values penalize new tokens
            based on their existing frequency in the text so far, decreasing the
            model's likelihood to repeat the same line verbatim.
        logit_bias:
          type:
            - object
            - 'null'
          description: >-
            Modify the likelihood of specified tokens appearing in the
            completion. Accepts a json object that maps tokens (specified by
            their token ID in the tokenizer) to an associated bias value from
            -100 to 100.
          additionalProperties:
            type: integer
            format: int32
          propertyNames:
            type: string
        logprobs:
          type:
            - boolean
            - 'null'
          description: >-
            Whether to return log probabilities of the output tokens or not. If
            true, returns the log probabilities of each output token returned in
            the content of message.
        max_completion_tokens:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            The maximum number of tokens that can be generated in the chat
            completion. The total length of input tokens and generated tokens is
            limited by the model's context length.
          minimum: 0
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
          description: A list of messages comprising the conversation so far.
        metadata:
          type:
            - object
            - 'null'
          description: >-
            Developer-defined tags and values used for filtering completions in
            the dashboard.
          additionalProperties:
            type: string
          propertyNames:
            type: string
        modalities:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            Output types that you would like the model to generate for this
            request. Most models are capable of generating text, which is the
            default. The gpt-4o-audio-preview model can also be used to generate
            audio.
        model:
          type: string
          description: ID of the model to use.
        'n':
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            How many chat completion choices to generate for each input message.
            Note that you will be charged based on the number of generated
            tokens across all of the choices. Keep n as 1 to minimize costs.
          minimum: 0
        parallel_tool_calls:
          type:
            - boolean
            - 'null'
          description: Whether to enable parallel function calling during tool use.
        prediction:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/PredictionContent'
              description: >-
                Configuration for a Predicted Output, which can greatly improve
                response times when large parts of the model response are known
                ahead of time. This is most common when you are regenerating a
                file with only minor changes to most of the content.
        presence_penalty:
          type:
            - number
            - 'null'
          format: float
          description: >-
            Number between -2.0 and 2.0. Positive values penalize new tokens
            based on whether they appear in the text so far, increasing the
            model's likelihood to talk about new topics.
        prompt_cache_key:
          type:
            - string
            - 'null'
          description: >-
            Developer-supplied key for grouping related requests, used to
            mitigate model latency and performance issues for high-traffic
            applications. This key will be used on best effort basis to route
            requests to models that have seen the same prompt_cache_key values
            recently.
        reasoning_effort:
          type:
            - string
            - 'null'
          description: >-
            Constrains effort on reasoning for reasoning models. Currently
            supported values are low, medium, and high. Reducing reasoning
            effort can result in faster responses and fewer tokens used on
            reasoning in a response.
        response_format:
          description: >-
            An object specifying the format that the model must output.
            Compatible with GPT-4 Turbo and all GPT-3.5 Turbo models newer than
            gpt-3.5-turbo-1106. Setting to { "type": "json_schema",
            "json_schema": {...} } enables Structured Outputs which ensures the
            model will match your supplied JSON schema.
        seed:
          type:
            - integer
            - 'null'
          format: int64
          description: >-
            This feature is in Beta. If specified, our system will make a best
            effort to sample deterministically, such that repeated requests with
            the same seed and parameters should return the same result.
            Determinism is not guaranteed.
        service_tier:
          type:
            - string
            - 'null'
          description: >-
            Specifies the latency tier to use for processing the request. This
            parameter is relevant for customers subscribed to the scale tier
            service. If set to 'auto', the system will utilize scale tier
            credits until they are exhausted. If set to 'default', the request
            will be processed using the default service tier with a lower uptime
            SLA and no latency guarantee.
        stop:
          type:
            - array
            - 'null'
          items:
            type: string
          description: Up to 4 sequences where the API will stop generating further tokens.
        store:
          type:
            - boolean
            - 'null'
          description: >-
            Whether or not to store the output of this chat completion request
            for use in our model distillation or evals products.
        stream:
          type:
            - boolean
            - 'null'
          description: >-
            If set, partial message deltas will be sent. Tokens will be sent as
            data-only server-sent events as they become available, with the
            stream terminated by a data: [DONE] message.
        stream_options:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/StreamOptions'
              description: >-
                Options for streaming response. Only set this when you set
                stream: true.
        temperature:
          type:
            - number
            - 'null'
          format: float
          description: >-
            What sampling temperature to use, between 0 and 2. Higher values
            like 0.8 will make the output more random, while lower values like
            0.2 will make it more focused and deterministic.
        tool_choice:
          description: >-
            Controls which (if any) tool is called by the model. none means the
            model will not call any tool and instead generates a message. auto
            means the model can pick between generating a message or calling one
            or more tools. required means the model must call one or more tools.
            Specifying a particular tool via {"type": "function", "function":
            {"name": "my_function"}} forces the model to call that tool.
        tools:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/Tool'
          description: >-
            A list of tools the model may call. Currently, only functions are
            supported as a tool. Use this to provide a list of functions the
            model may generate JSON inputs for.
        top_logprobs:
          type:
            - integer
            - 'null'
          format: int32
          description: >-
            An integer between 0 and 20 specifying the number of most likely
            tokens to return at each token position, each with an associated log
            probability. logprobs must be set to true if this parameter is used.
          minimum: 0
        top_p:
          type:
            - number
            - 'null'
          format: float
          description: >-
            An alternative to sampling with temperature, called nucleus
            sampling, where the model considers the results of the tokens with
            top_p probability mass. So 0.1 means only the tokens comprising the
            top 10% probability mass are considered.
        user:
          type:
            - string
            - 'null'
          description: >-
            A unique identifier representing your end-user, which can help
            OpenAI to monitor and detect abuse.
    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'
    AudioParameters:
      type: object
      description: >-
        Parameters for audio output. Required when audio output is requested
        with modalities: ["audio"].
      required:
        - voice
        - format
      properties:
        format:
          type: string
          description: >-
            Specifies the output audio format. Must be one of wav, mp3, flac,
            opus, or pcm16.
        voice:
          type: string
          description: >-
            The voice the model should use to respond. Supported voices are
            alloy, ash, ballad, coral, echo fable, onyx, nova, sage, shimmer,
            and verse.
    ChatMessage:
      oneOf:
        - type: object
          required:
            - content
            - role
          properties:
            content:
              $ref: '#/components/schemas/MessageContent'
              description: The contents of the developer message.
            name:
              type:
                - string
                - 'null'
              description: >-
                An optional name for the participant. Provides the model
                information to differentiate between participants of the same
                role.
            role:
              type: string
              enum:
                - developer
        - type: object
          required:
            - content
            - role
          properties:
            content:
              $ref: '#/components/schemas/MessageContent'
              description: The contents of the system message.
            name:
              type:
                - string
                - 'null'
              description: >-
                An optional name for the participant. Provides the model
                information to differentiate between participants of the same
                role.
            role:
              type: string
              enum:
                - system
        - type: object
          required:
            - content
            - role
          properties:
            content:
              $ref: '#/components/schemas/MessageContent'
              description: The contents of the user message.
            name:
              type:
                - string
                - 'null'
              description: >-
                An optional name for the participant. Provides the model
                information to differentiate between participants of the same
                role.
            role:
              type: string
              enum:
                - user
        - type: object
          required:
            - content
            - role
          properties:
            audio:
              oneOf:
                - type: 'null'
                - $ref: '#/components/schemas/AssistantAudioId'
                  description: An object that references an audio output from the model.
            content:
              $ref: '#/components/schemas/MessageContent'
              description: The contents of the assistant message.
            name:
              type:
                - string
                - 'null'
              description: >-
                An optional name for the participant. Provides the model
                information to differentiate between participants of the same
                role.
            refusal:
              type:
                - string
                - 'null'
              description: The refusal message generated by the model.
            role:
              type: string
              enum:
                - assistant
            tool_calls:
              type:
                - array
                - 'null'
              items:
                $ref: '#/components/schemas/ToolCall'
              description: The tool calls generated by the model, such as function calls.
        - type: object
          required:
            - content
            - tool_call_id
            - role
          properties:
            content:
              $ref: '#/components/schemas/MessageContent'
              description: The contents of the tool message.
            role:
              type: string
              enum:
                - tool
            tool_call_id:
              type: string
              description: Tool call that this message is responding to.
      description: A message in a chat completion request or response.
    PredictionContent:
      type: object
      description: >-
        Configuration for a Predicted Output, which can greatly improve response
        times when large parts of the model response are known ahead of time.
      required:
        - type
        - content
      properties:
        content:
          type: string
          description: >-
            The content that should be used as the basis for the prediction.
            This should be the exact content of a previous response from the
            model, including all formatting, which you would like the model to
            use as a template for the current response.
        type:
          type: string
          description: The prediction type. Currently only "content" is supported.
    StreamOptions:
      type: object
      description: 'Options for streaming response. Only set this when you set stream: true.'
      properties:
        include_usage:
          type:
            - boolean
            - 'null'
          description: >-
            If set, an additional chunk will be streamed before the data: [DONE]
            message. The usage field on this chunk shows the token usage
            statistics for the entire request, and the choices field will always
            be an empty array. All other chunks will also include a usage field,
            but with a null value.
    Tool:
      type: object
      description: A tool the model may call.
      required:
        - function
        - type
      properties:
        function:
          $ref: '#/components/schemas/Function'
          description: The function definition.
        type:
          type: string
          description: The type of the tool. Currently, only `function` is supported.
    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
    MessageContent:
      oneOf:
        - type: string
          description: Plain text content
        - type: array
          items:
            $ref: '#/components/schemas/ContentPart'
          description: Array of structured content parts supporting multimodal inputs
      description: >-
        Message content, which can be either plain text or an array of
        structured content parts (text, images, files, audio)
    AssistantAudioId:
      type: object
      description: References an audio output from the assistant.
      required:
        - id
      properties:
        id:
          type: string
          description: Unique identifier for the audio output.
    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.
    Function:
      type: object
      description: The definition of a function that can be called by the model.
      required:
        - name
      properties:
        description:
          type:
            - string
            - 'null'
          description: >-
            A description of what the function does, used by the model to choose
            when and how to call the function.
        name:
          type: string
          description: >-
            The name of the function to be called. Must be a-z, A-Z, 0-9, or
            contain underscores and dashes, with a maximum length of 64.
        parameters:
          description: >-
            The parameters the functions accepts, described as a JSON Schema
            object. See the guide for examples, and the JSON Schema reference
            for documentation about the format. Omitting parameters defines a
            function with an empty parameter list.
        strict:
          type:
            - boolean
            - 'null'
          description: >-
            Whether to enable strict schema adherence when generating the
            function call. If set to true, the model will follow the exact
            schema defined in the parameters field. Only a subset of JSON Schema
            is supported when strict is true.
    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.
    ContentPart:
      oneOf:
        - type: object
          description: Text content part
          required:
            - text
            - type
          properties:
            text:
              type: string
              description: The text content
            type:
              type: string
              enum:
                - input_text
        - type: object
          description: Image content part
          required:
            - detail
            - type
          properties:
            detail:
              type: string
              description: Level of detail for image processing ("low", "high", "auto")
            file_id:
              type:
                - string
                - 'null'
              description: ID of a previously uploaded file containing the image
            image_url:
              type:
                - string
                - 'null'
              description: URL of the image to process
            type:
              type: string
              enum:
                - input_image
        - type: object
          description: File content part for document processing
          required:
            - type
          properties:
            file_data:
              type:
                - string
                - 'null'
              description: Base64-encoded file data
            file_id:
              type:
                - string
                - 'null'
              description: ID of a previously uploaded file
            file_url:
              type:
                - string
                - 'null'
              description: URL of the file to process
            filename:
              type:
                - string
                - 'null'
              description: Name of the file
            type:
              type: string
              enum:
                - input_file
        - type: object
          description: Audio content part
          required:
            - input_audio
            - type
          properties:
            input_audio:
              $ref: '#/components/schemas/Audio'
              description: Audio input data and format
            type:
              type: string
              enum:
                - input_audio
      description: >-
        A part of message content, supporting different content types (text,
        images, files, audio) for multimodal input
    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.
    Audio:
      type: object
      description: Audio input data
      required:
        - data
        - format
      properties:
        data:
          type: string
          description: Base64-encoded audio data
        format:
          type: string
          description: Audio format (e.g., "wav", "mp3")

````