---
title: "Create a model response for the given string of prompts."
method: POST
path: "/v1/chat/completions"
tags: ["router"]
---

# Create a model response for the given string of prompts.

`POST /v1/chat/completions`

## Request

- Base URL: `https://docs.sudoapp.dev` (the document declares no server; this is the origin it was published from)
- URL: `https://docs.sudoapp.dev/v1/chat/completions`
- Auth: HTTP bearer

## Request body

- ChatCompletionRequestJson
  - `audio` object, nullable: Parameters for audio output. Required when audio output is requested with modalities: ["audio"].
    - `format` 'wav' | 'mp3' | 'flac' | 'opus' | 'pcm16': Specifies the output audio format. Must be one of wav, mp3, flac, opus, or pcm16.
    - `voice` 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer': Specifies the voice type. Supported voices are alloy, echo, fable, onyx, nova, and shimmer.
  - `frequency_penalty` number, float, nullable: 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` object, nullable: 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. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token.
  - `logprobs` boolean, nullable: 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` integer, nullable: An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.
  - `messages` ChatMessage[], required: A list of messages comprising the conversation so far. Depending on the model you use, different message types (modalities) are supported, like text, images, and audio.
    - `content` union, required
      - string: Simple text content
      - ContentPart[]: Array of content parts for multimodal input
        - union
          - object: Text content part.
            - `text` string, required
            - `type` string, required
          - object: Image content part.
            - `image_url` object, required
              - …
            - `type` string, required
          - object: Audio content part.
            - `input_audio` object, required
              - …
            - `type` string, required: The type of the content part. Always input_audio.
          - object: File content part.
            - `file` object, required
              - …
            - `type` string, required: The type of the content part. Always file.
    - `name` string, nullable
    - `role` string, required
    - `tool_call_id` string, nullable
    - `tool_calls` ToolCall[], nullable
      - `function` ToolCallFunction, required
        - `arguments` string, required
        - `name` string, required
      - `id` string, required
      - `type` string, required
  - `metadata` object, nullable: Developer-defined tags and values used for filtering completions in the stored completions dashboard.
  - `modalities` string[], nullable: Output types that you would like the model to generate for this request. Most models are capable of generating text, which is the default: ["text"]. The gpt-4o-audio-preview model can also be used to generate audio. To request that this model generate both text and audio responses, you can use: ["text", "audio"].
  - `model` string, required: Model name used to generate the response, like gpt-4o or deepseek-reasoner. Sudo offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the [docs](https://docs.sudoapp.dev/overview/models) to browse and compare available models.
  - `n` integer, nullable: 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.
  - `parallel_tool_calls` boolean, nullable: Whether to enable parallel function calling during tool use.
  - `prediction` object, nullable: 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.
    - `type` 'content'
    - `content` string: The predicted content for the completion.
  - `presence_penalty` number, float, nullable: 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` string, nullable: A unique identifier for caching prompts to improve response times for repeated requests.
  - `reasoning_effort` 'low' | 'medium' | 'high', nullable: o1 models only. 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` union: An object specifying the format that the model must output. Compatible with GPT-4o, GPT-4o mini, 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 guarantee the model will match your supplied JSON schema. Setting to { "type": "json_object" } enables JSON mode, which guarantees the message the model generates is valid JSON.
    - object
      - `type` 'text', required
    - object
      - `type` 'json_object', required
    - object
      - `type` 'json_schema', required
      - `json_schema` object, required: The JSON schema definition for structured outputs.
        - `name` string, required: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
        - `description` string: A description of what the response format is for, used by the model to determine how to respond in the format.
        - `schema` object, required: The schema for the response format, described as a JSON Schema object.
        - `strict` boolean: Whether to enable strict schema adherence when generating the output.
  - `seed` integer, nullable: 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 isn't guaranteed, and you should refer to the system_fingerprint response parameter to monitor changes in the backend.
  - `service_tier` 'auto' | 'default', nullable: Specifies the latency tier to use for processing the request. This parameter is relevant for customers subscribed to the scale tier service.
  - `stop` string[], nullable: Not supported with latest reasoning models o3 and o4-mini. Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
  - `store` boolean, nullable: Whether or not to store the output of this chat completion request for use in our model distillation or evaluation products.
  - `stream` false: If set, partial message deltas will be sent, like in ChatGPT. For JSON responses, this must be false.
  - `stream_options` object, nullable: Options for streaming response. Only set this when you set stream: true.
    - `include_usage` boolean: 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.
  - `temperature` number, float, nullable: 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. We generally recommend altering this or top_p but not both.
  - `tool_choice` union: Controls which (if any) tool is called by the model. none means the model won't 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. none is the default when no tools are present. auto is the default if tools are present.
    - 'none' | 'auto' | 'required'
    - object
      - `type` 'function', required
      - `function` object, required
        - `name` string, required
  - `tools` Tool[], nullable: 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. A max of 128 functions are supported.
    - `function` Function, required
      - `description` string, nullable
      - `name` string, required
      - `parameters` unknown
      - `strict` boolean, nullable
    - `type` string, required
  - `top_logprobs` integer, nullable: 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.
  - `top_p` number, float, nullable: 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. We generally recommend altering this or temperature but not both.

## Response `200`

Chat completion created successfully

- ChatCompletion
  - `choices` Choice[], required
    - `finish_reason` string, required
    - `index` integer, required
    - `logprobs` unknown
    - `message` MessageResponse, required
      - `annotations` unknown
      - `audio` unknown
      - `content` string, nullable
      - `refusal` string, nullable
      - `role` string, required
      - `tool_calls` ToolCall[], nullable
        - `function` ToolCallFunction, required
          - `arguments` string, required
          - `name` string, required
        - `id` string, required
        - `type` string, required
  - `created` integer, required
  - `id` string, required
  - `model` string, required
  - `object` string, required
  - `service_tier` string, nullable
  - `system_fingerprint` string, nullable
  - `usage` Usage, required
    - `completion_tokens` integer, required
    - `completion_tokens_details` unknown
    - `prompt_tokens` integer, required
    - `prompt_tokens_details` unknown
    - `total_tokens` integer, required
  - `metadata` object, nullable: Developer-defined metadata attached to the completion.

## Other responses

- `400`: Bad request
- `401`: Unauthorized
- `500`: Internal server error
- `502`: Bad gateway error

---

[API](https://skmtc.dev/sudoapp/apis/sudo-api.md) - [All operations](https://skmtc.dev/sudoapp/apis/sudo-api/llms.txt) - [OpenAPI document](https://skmtc.dev/sudoapp/apis/sudo-api/revisions/7d59684bf816?raw)
