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

# Create completion



## OpenAPI

````yaml create-completion.yaml POST /v1/completions
openapi: 3.0.1
info:
  title: ''
  version: 1.0.0
servers:
  - url: https://tokensmind.ai
    description: Production
security:
  - bearer: []
paths:
  /v1/completions:
    post:
      tags: []
      summary: Native OpenAI format
      description: Generates a model completion from the given prompt and parameters
      operationId: createCompletion
      parameters:
        - name: Content-Type
          in: header
          description: ''
          required: true
          example: application/json
          schema:
            type: string
        - name: Authorization
          in: header
          description: ''
          required: true
          example: 'Bearer authentication: Bearer {{API key}}.'
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              x-apifox-refs: {}
              x-apifox-orders:
                - model
                - prompt
                - stream
                - stream_options
                - max_tokens
                - 'n'
                - seed
                - frequency_penalty
                - presence_penalty
                - repetition_penalty
                - stop
                - temperature
                - top_p
                - top_k
                - min_p
                - logit_bias
                - logprobs
                - best_of
                - 01KP5NABP505Q46C0NW8XXAPCD
              properties:
                model:
                  type: string
                  description: >-
                    Model name to use. See the model catalog on [TokensMind
                    AI](https://tokensmind.ai/pricing) for available names
                prompt:
                  type: string
                  description: >
                    Prompt used to generate the completion (may be a string,
                    array of strings, array of tokens, or array of token
                    arrays).
                max_tokens:
                  type: integer
                  description: >-
                    Maximum number of tokens to generate.

                    The sum of prompt tokens and max_tokens must not exceed the
                    model's context length.
                temperature:
                  type: number
                  description: >
                    Sampling temperature; default is 1, between 0 and 2. Higher
                    values (e.g. 0.8) make output more random; lower values
                    (e.g. 0.2) make it more focused and deterministic.


                    We generally recommend changing either this or top_p, not
                    both.
                  minimum: 0
                  maximum: 2
                  nullable: true
                top_p:
                  type: number
                  minimum: 0
                  maximum: 1
                  exclusiveMinimum: true
                  description: >-
                    An alternative to temperature, called nucleus sampling: the
                    model considers tokens whose cumulative probability mass is
                    top_p. So 0.1 means only the top 10% probability mass is
                    considered. We generally recommend changing either this or
                    temperature, not both.
                  nullable: true
                'n':
                  type: integer
                  description: >
                    Note: This parameter can generate many completions and may
                    consume your token quota quickly. Use with care and set
                    max_tokens and stop to reasonable values.
                  minimum: 0
                  maximum: 128
                  exclusiveMinimum: true
                  exclusiveMaximum: true
                  nullable: true
                stream:
                  type: boolean
                  description: >
                    Whether to stream tokens. Defaults to false. When enabled,
                    tokens are sent as data-only server-sent events (SSE),
                    ending with a data: [DONE] message.
                  nullable: true
                stop:
                  type: string
                  description: >-
                    Up to 4 sequences where the API will stop generating further
                    tokens. Returned text includes the stop sequence.
                stream_options:
                  type: object
                  properties:
                    include_usage:
                      type: boolean
                      description: >
                        When set, an additional chunk is streamed before the
                        data: [DONE] message. That chunk's usage field shows
                        token usage for the entire request, while choices is
                        always an empty array. Other chunks may also include a
                        usage field set to null.
                  x-apifox-orders:
                    - include_usage
                  description: |
                    Streaming options. Only set when stream is true.
                  required:
                    - include_usage
                seed:
                  type: integer
                  description: >-
                    If specified, the system will try to sample
                    deterministically so repeated requests with the same seed
                    and parameters return the same result.
                  nullable: true
                frequency_penalty:
                  type: number
                  description: >
                    Default 0. Positive values penalize new tokens based on
                    their frequency in the text so far, reducing repetition.


                    For mild repetition reduction, try roughly 0.1 to 1. For
                    strong suppression, you can increase toward 2, but quality
                    may drop. Negative values encourage repetition.


                    See also presence_penalty for a fixed penalty on tokens that
                    appear at least once
                  default: 0
                  minimum: -2
                  maximum: 2
                  exclusiveMinimum: true
                  exclusiveMaximum: true
                  nullable: true
                presence_penalty:
                  type: number
                  description: >-
                    Default 0. Positive values penalize new tokens based on
                    whether they appear in the text so far, encouraging new
                    topics.


                    For mild repetition reduction, try roughly 0.1 to 1. For
                    strong suppression, you can increase toward 2, but quality
                    may drop significantly. Negative values encourage
                    repetition.


                    See also frequency_penalty for frequency-based penalization
                  minimum: -2
                  maximum: 2
                  exclusiveMinimum: true
                  exclusiveMaximum: true
                  nullable: true
                repetition_penalty:
                  type: number
                  description: >-
                    Penalty applied to repeated tokens to discourage or
                    encourage repetition. 1.0 means no penalty and free
                    repetition. Values above 1.0 penalize repetition. Values
                    between 0.0 and 1.0 reward repetition. A balanced value is
                    often around 1.2. On decoder-only models, the penalty
                    applies to both the prompt and the generated output.
                  minimum: 0
                  maximum: 2
                  exclusiveMinimum: true
                  exclusiveMaximum: true
                  nullable: true
                top_k:
                  type: number
                  minimum: 1
                  maximum: 128
                  exclusiveMinimum: true
                  exclusiveMaximum: true
                  description: >-
                    Top-k sampling keeps only the k most likely next tokens and
                    redistributes probability mass among them. k controls how
                    many candidates are considered per step.
                  nullable: true
                min_p:
                  type: number
                  description: >
                    Minimum relative probability for a token to be considered,
                    compared to the most likely token.
                  nullable: true
                logit_bias:
                  type: object
                  properties: {}
                  x-apifox-orders: []
                  description: >
                    Defaults to null. Modifies likelihood of specified tokens in
                    the completion. Accepts a JSON object mapping token IDs to
                    bias values from -100 to 100.
                01KP5NABP505Q46C0NW8XXAPCD:
                  x-tmp-pending-properties: true
                logprobs:
                  type: integer
                  description: >
                    Returns log probabilities for the top logprobs output tokens
                    at each step, including the probability of the selected
                    token. For example, if logprobs is 5, the API returns the
                    top 5 tokens' logprobs per step.


                    The maximum value for logprobs is 5.
                  nullable: true
                best_of:
                  type: integer
                  description: >
                    Defaults to 1. Generates best_of completions on the server
                    and returns the "best" one (highest per-token log
                    probability). Cannot be used with streaming.


                    When used with n, best_of is the number of candidate
                    completions and n is how many to return. best_of must be
                    greater than n.


                    Note: This can consume your token quota quickly. Use with
                    care and set max_tokens and stop reasonably.
              required:
                - model
                - prompt
                - best_of
            example: |-
              curl --request POST \
                --url https: //api.jiekou.ai/openai/v1/completions \
                --header 'Authorization: <authorization>' \
                --header 'Content-Type: <content-type>' \
                --data '
              {
                  "model": "<string>",
                  "prompt": "<string>",
                  "max_tokens": 123,
                  "stream": {},
                  "stream_options": {
                      "include_usage": true
                  },
                  "n": {},
                  "seed": {},
                  "frequency_penalty": {},
                  "presence_penalty": {},
                  "repetition_penalty": {},
                  "stop": {},
                  "temperature": {},
                  "top_p": {},
                  "top_k": {},
                  "min_p": {},
                  "logit_bias": {},
                  "logprobs": {},
                  "best_of": 123
              }
              '
        required: true
      responses:
        '200':
          description: Completion created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CompletionResponse'
              example:
                choices:
                  - finish_reason: <string>
                    index: 123
                    logprobs:
                      text_offset:
                        - {}
                      token_logprobs:
                        - {}
                      tokens:
                        - {}
                      top_logprobs:
                        - '{key}': 123
                    text: <string>
                created: 123
                id: <string>
                model: <string>
                object: <string>
                usage:
                  completion_tokens: 123
                  prompt_tokens: 123
                  total_tokens: 123
          headers: {}
          x-apifox-name: Success
          x-apifox-ordering: 0
      deprecated: false
      security: []
components:
  schemas:
    CompletionResponse:
      type: object
      properties:
        id:
          type: string
        object:
          type: string
          example: text_completion
        created:
          type: integer
        model:
          type: string
        choices:
          type: array
          items:
            type: object
            properties:
              text:
                type: string
              index:
                type: integer
              finish_reason:
                type: string
            x-apifox-orders:
              - text
              - index
              - finish_reason
            x-apifox-ignore-properties: []
        usage:
          $ref: '#/components/schemas/Usage'
      x-apifox-orders:
        - id
        - object
        - created
        - model
        - choices
        - usage
      x-apifox-ignore-properties: []
      x-apifox-folder: ''
    Usage:
      type: object
      properties:
        prompt_tokens:
          type: integer
          description: Prompt tokens
        completion_tokens:
          type: integer
          description: Completion tokens
        total_tokens:
          type: integer
          description: Total tokens
        prompt_tokens_details:
          type: object
          properties:
            cached_tokens:
              type: integer
            text_tokens:
              type: integer
            audio_tokens:
              type: integer
            image_tokens:
              type: integer
          x-apifox-orders:
            - cached_tokens
            - text_tokens
            - audio_tokens
            - image_tokens
          x-apifox-ignore-properties: []
        completion_tokens_details:
          type: object
          properties:
            text_tokens:
              type: integer
            audio_tokens:
              type: integer
            reasoning_tokens:
              type: integer
          x-apifox-orders:
            - text_tokens
            - audio_tokens
            - reasoning_tokens
          x-apifox-ignore-properties: []
      x-apifox-orders:
        - prompt_tokens
        - completion_tokens
        - total_tokens
        - prompt_tokens_details
        - completion_tokens_details
      x-apifox-ignore-properties: []
      x-apifox-folder: ''
  securitySchemes:
    bearer:
      type: http
      scheme: bearer

````