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

# Create chat completion

> Generate a JSON response or SSE stream from chat messages. Requires inference:write. Supports functions, web_search_options, model-specific reasoning and structured outputs. n accepts 1–128; reservations account for every completion.



## OpenAPI

````yaml /openapi.json post /v1/chat/completions
openapi: 3.1.0
info:
  title: Limitless API
  version: 0.2.0
  description: >-
    Customer inference, scoped organization administration, policies, and health
    probes for Limitless at https://trylimitless.ai. This deployment uses
    sandbox credits and test payments but sends real inference requests. Model
    features depend on the active backend. The OpenAI SDK base URL is
    https://trylimitless.ai/v1.
servers:
  - url: https://trylimitless.ai
    description: >-
      Limitless sandbox API: test payments and real inference. OpenAI SDK
      clients add /v1 to this origin.
security:
  - customerKey: []
tags:
  - name: Health
  - name: Models
  - name: Inference
  - name: Credits
  - name: Organization
  - name: Projects
  - name: Project keys
  - name: Admin keys
  - name: Spending limits
  - name: Reports
  - name: Policies
paths:
  /v1/chat/completions:
    post:
      tags:
        - Inference
      summary: Create chat completion
      description: >-
        Generate a JSON response or SSE stream from chat messages. Requires
        inference:write. Supports functions, web_search_options, model-specific
        reasoning and structured outputs. n accepts 1–128; reservations account
        for every completion.
      operationId: createChatCompletion
      parameters:
        - name: X-Limitless-Session-ID
          in: header
          required: false
          schema:
            type: string
            minLength: 1
            maxLength: 512
          description: >-
            Optional cache-affinity hint, isolated to this organization and
            project. X-Abliteration-Session-ID is accepted for compatibility.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
            text/event-stream:
              schema:
                type: string
                description: >-
                  SSE records emitted when stream=true. Parse this endpoint’s
                  native event format; network chunks can split events.
          description: Successful response.
          headers:
            X-Request-ID:
              description: Gateway request ID for Activity and support.
              schema:
                type: string
                format: uuid
        '400':
          $ref: '#/components/responses/Api400'
        '401':
          $ref: '#/components/responses/Api401'
        '402':
          $ref: '#/components/responses/Api402'
        '403':
          $ref: '#/components/responses/Api403'
        '404':
          $ref: '#/components/responses/Api404'
        '409':
          $ref: '#/components/responses/Api409'
        '413':
          $ref: '#/components/responses/Api413'
        '415':
          $ref: '#/components/responses/Api415'
        '422':
          $ref: '#/components/responses/Api422'
        '429':
          $ref: '#/components/responses/Api429'
        '500':
          $ref: '#/components/responses/Api500'
        '501':
          $ref: '#/components/responses/Api501'
        '502':
          $ref: '#/components/responses/Api502'
        '503':
          $ref: '#/components/responses/Api503'
        '504':
          $ref: '#/components/responses/Api504'
      security:
        - customerKey: []
        - customerHeaderKey: []
components:
  schemas:
    ChatCompletionRequest:
      properties:
        model:
          type: string
          minLength: 1
          maxLength: 200
        messages:
          items:
            $ref: '#/components/schemas/ChatCompletionMessage'
          type: array
          minItems: 1
        policy_ids:
          items:
            type: string
            maxLength: 120
            minLength: 1
          type: array
          maxItems: 1000
          description: >-
            Published Limitless policy IDs. These add to automatically attached
            policies; provider IDs are not accepted.
        stream:
          type: boolean
          default: false
        max_tokens:
          anyOf:
            - type: integer
              maximum: 999990
              minimum: 1
            - type: 'null'
          description: >-
            Positive output bound; limited by the model’s configured maximum.
            Chat/Responses default to 1,024 when omitted. Send exactly one
            output-bound field.
        max_completion_tokens:
          anyOf:
            - type: integer
              maximum: 999990
              minimum: 1
            - type: 'null'
          description: >-
            Positive output bound; limited by the model’s configured maximum.
            Chat/Responses default to 1,024 when omitted. Send exactly one
            output-bound field.
        temperature:
          anyOf:
            - type: number
            - type: 'null'
        top_p:
          anyOf:
            - type: number
            - type: 'null'
        frequency_penalty:
          anyOf:
            - type: number
              maximum: 2
              minimum: -2
            - type: 'null'
        presence_penalty:
          anyOf:
            - type: number
              maximum: 2
              minimum: -2
            - type: 'null'
        logit_bias:
          anyOf:
            - additionalProperties:
                type: number
                maximum: 100
                minimum: -100
              type: object
            - type: 'null'
        'n':
          anyOf:
            - type: integer
              maximum: 128
              minimum: 1
            - type: 'null'
        seed:
          anyOf:
            - type: integer
            - type: 'null'
        stop:
          anyOf:
            - type: string
            - items:
                type: string
              type: array
            - type: 'null'
        stream_options:
          anyOf:
            - $ref: '#/components/schemas/ChatCompletionStreamOptions'
            - type: 'null'
        thinking:
          anyOf:
            - type: boolean
            - type: 'null'
        reasoning:
          anyOf:
            - $ref: '#/components/schemas/ChatCompletionReasoningOptions'
            - type: 'null'
        reasoning_effort:
          anyOf:
            - type: string
              enum:
                - none
                - minimal
                - low
                - medium
                - high
                - xhigh
                - max
                - ultracode
            - type: 'null'
        include_reasoning:
          anyOf:
            - type: boolean
            - type: 'null'
        safety_identifier:
          anyOf:
            - type: string
              maxLength: 64
            - type: 'null'
        user:
          anyOf:
            - type: string
              maxLength: 512
            - type: 'null'
        structuredOutputs:
          type: boolean
        tools:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          description: >-
            Chat: function tools. Responses: functions and supported web_search
            aliases. Messages: custom functions, web_search_2025_03_05 and
            web_fetch_2025_03_05. See the tools guide.
        tool_choice:
          anyOf:
            - type: string
              enum:
                - none
                - auto
                - required
            - additionalProperties: true
              type: object
            - type: 'null'
        parallel_tool_calls:
          anyOf:
            - type: boolean
            - type: 'null'
        functions:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
        function_call:
          anyOf:
            - type: string
              enum:
                - none
                - auto
            - additionalProperties: true
              type: object
            - type: 'null'
        response_format:
          anyOf:
            - oneOf:
                - $ref: '#/components/schemas/ChatCompletionResponseFormatText'
                - $ref: '#/components/schemas/ChatCompletionResponseFormatJsonObject'
                - $ref: '#/components/schemas/ChatCompletionResponseFormatJsonSchema'
              discriminator:
                propertyName: type
                mapping:
                  json_object: '#/components/schemas/ChatCompletionResponseFormatJsonObject'
                  json_schema: '#/components/schemas/ChatCompletionResponseFormatJsonSchema'
                  text: '#/components/schemas/ChatCompletionResponseFormatText'
            - type: 'null'
        modalities:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
        verbosity:
          anyOf:
            - type: string
              enum:
                - low
                - medium
                - high
            - type: 'null'
        audio:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
        prediction:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
        store:
          type: boolean
          const: false
          default: false
          description: Responses are stateless; true is rejected.
        service_tier:
          anyOf:
            - type: string
            - type: 'null'
        prompt_cache_key:
          anyOf:
            - type: string
              maxLength: 512
            - type: 'null'
          description: >-
            Optional stable cache-affinity key, isolated to this organization
            and project.
          maxLength: 512
        prompt_cache_retention:
          anyOf:
            - type: string
              enum:
                - in_memory
                - 24h
            - type: 'null'
        logprobs:
          anyOf:
            - type: boolean
            - type: 'null'
        top_logprobs:
          anyOf:
            - type: integer
            - type: 'null'
        prompt_logprobs:
          anyOf:
            - type: integer
            - type: 'null'
        web_search_options:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
        cache_salt:
          anyOf:
            - type: string
            - type: 'null'
      additionalProperties: false
      type: object
      required:
        - model
        - messages
      description: >-
        Model-dependent request fields. Read the compatibility guide for
        supported combinations and limits.
    ChatCompletionResponse:
      properties:
        id:
          type: string
        object:
          type: string
          const: chat.completion
          default: chat.completion
        created:
          type: integer
        model:
          type: string
        choices:
          items:
            $ref: '#/components/schemas/ChatCompletionChoice'
          type: array
        usage:
          anyOf:
            - $ref: '#/components/schemas/ChatCompletionUsage'
            - type: 'null'
        system_fingerprint:
          anyOf:
            - type: string
            - type: 'null'
        service_tier:
          anyOf:
            - type: string
            - type: 'null'
        prompt_logprobs:
          anyOf:
            - items:
                anyOf:
                  - additionalProperties: true
                    type: object
                  - type: 'null'
              type: array
            - type: 'null'
      type: object
      required:
        - id
        - created
        - model
        - choices
    ChatCompletionMessage:
      properties:
        role:
          type: string
          enum:
            - system
            - developer
            - user
            - assistant
            - tool
            - function
        content:
          anyOf:
            - type: string
            - items:
                $ref: '#/components/schemas/ChatCompletionContentPart'
              type: array
            - type: 'null'
        reasoning:
          anyOf:
            - type: string
            - type: 'null'
        reasoning_content:
          anyOf:
            - type: string
            - type: 'null'
        name:
          anyOf:
            - type: string
            - type: 'null'
        tool_call_id:
          anyOf:
            - type: string
            - type: 'null'
        tool_calls:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
        function_call:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
        model_id:
          type: string
          maxLength: 256
          minLength: 1
      additionalProperties: false
      type: object
      required:
        - role
    ChatCompletionStreamOptions:
      properties:
        include_usage:
          anyOf:
            - type: boolean
            - type: 'null'
      additionalProperties: false
      type: object
    ChatCompletionReasoningOptions:
      properties:
        enabled:
          anyOf:
            - type: boolean
            - type: 'null'
        effort:
          anyOf:
            - type: string
              enum:
                - none
                - minimal
                - low
                - medium
                - high
                - xhigh
                - max
                - ultracode
            - type: 'null'
        max_tokens:
          anyOf:
            - type: integer
              maximum: 999990
              minimum: 1
            - type: 'null'
        exclude:
          anyOf:
            - type: boolean
            - type: 'null'
      additionalProperties: false
      type: object
    ChatCompletionResponseFormatText:
      properties:
        type:
          type: string
          const: text
      additionalProperties: false
      type: object
      required:
        - type
    ChatCompletionResponseFormatJsonObject:
      properties:
        type:
          type: string
          const: json_object
      additionalProperties: false
      type: object
      required:
        - type
    ChatCompletionResponseFormatJsonSchema:
      properties:
        type:
          type: string
          const: json_schema
        json_schema:
          $ref: '#/components/schemas/ChatCompletionResponseFormatJsonSchemaSpec'
      additionalProperties: false
      type: object
      required:
        - type
        - json_schema
    ChatCompletionChoice:
      properties:
        index:
          type: integer
        message:
          $ref: '#/components/schemas/ChatCompletionResponseMessage'
        logprobs:
          anyOf:
            - {}
            - type: 'null'
        finish_reason:
          anyOf:
            - type: string
            - type: 'null'
      type: object
      required:
        - index
        - message
    ChatCompletionUsage:
      properties:
        prompt_tokens:
          type: integer
        completion_tokens:
          type: integer
        total_tokens:
          type: integer
        prompt_tokens_details:
          anyOf:
            - additionalProperties:
                anyOf:
                  - type: integer
                  - additionalProperties:
                      type: integer
                    type: object
                  - type: 'null'
              type: object
            - type: 'null'
        completion_tokens_details:
          anyOf:
            - additionalProperties:
                anyOf:
                  - type: integer
                  - type: 'null'
              type: object
            - type: 'null'
      type: object
      required:
        - prompt_tokens
        - completion_tokens
        - total_tokens
    ErrorResponse:
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
      type: object
      required:
        - error
    ChatCompletionContentPart:
      properties:
        type:
          anyOf:
            - type: string
            - type: 'null'
        text:
          anyOf:
            - type: string
            - type: 'null'
        image_url:
          anyOf:
            - {}
            - type: 'null'
      additionalProperties: true
      type: object
    ChatCompletionResponseFormatJsonSchemaSpec:
      properties:
        name:
          type: string
          maxLength: 128
          minLength: 1
        description:
          anyOf:
            - type: string
              maxLength: 2048
            - type: 'null'
        schema:
          additionalProperties: true
          type: object
        strict:
          anyOf:
            - type: boolean
            - type: 'null'
      additionalProperties: false
      type: object
      required:
        - name
        - schema
    ChatCompletionResponseMessage:
      properties:
        role:
          type: string
          enum:
            - system
            - developer
            - user
            - assistant
            - tool
        content:
          anyOf:
            - type: string
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
        refusal:
          anyOf:
            - type: string
            - type: 'null'
        reasoning:
          anyOf:
            - type: string
            - type: 'null'
        reasoning_content:
          anyOf:
            - type: string
            - type: 'null'
        name:
          anyOf:
            - type: string
            - type: 'null'
        tool_call_id:
          anyOf:
            - type: string
            - type: 'null'
        tool_calls:
          anyOf:
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
        function_call:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
        annotations:
          anyOf:
            - items:
                $ref: '#/components/schemas/ChatCompletionMessageAnnotation'
              type: array
            - type: 'null'
      type: object
      required:
        - role
    ErrorDetail:
      properties:
        code:
          type: string
        message:
          type: string
        type:
          type: string
          description: Error category; policy failures use policy_error.
        param:
          anyOf:
            - type: string
            - type: 'null'
        request_id:
          type: string
        doc_url:
          anyOf:
            - type: string
            - type: 'null'
      type: object
      required:
        - code
        - message
        - type
    ChatCompletionMessageAnnotation:
      properties:
        type:
          type: string
          const: url_citation
          default: url_citation
        url_citation:
          $ref: '#/components/schemas/ChatCompletionUrlCitation'
      type: object
      required:
        - url_citation
    ChatCompletionUrlCitation:
      properties:
        url:
          type: string
        title:
          type: string
        start_index:
          type: integer
          minimum: 0
        end_index:
          type: integer
          minimum: 0
      type: object
      required:
        - url
        - title
        - start_index
        - end_index
  responses:
    Api400:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: Request validation failed.
      headers:
        X-Request-ID:
          description: Gateway request ID for Activity and support.
          schema:
            type: string
            format: uuid
    Api401:
      headers:
        X-Request-ID:
          description: Gateway request ID for Activity and support.
          schema:
            type: string
            format: uuid
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: Missing or invalid credential.
    Api402:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: Available credit or spending cap cannot cover admission.
      headers:
        X-Request-ID:
          description: Gateway request ID for Activity and support.
          schema:
            type: string
            format: uuid
    Api403:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: Credential scope or policy denied this operation.
      headers:
        X-Request-ID:
          description: Gateway request ID for Activity and support.
          schema:
            type: string
            format: uuid
    Api404:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: Resource or model not found in the caller’s organization.
      headers:
        X-Request-ID:
          description: Gateway request ID for Activity and support.
          schema:
            type: string
            format: uuid
    Api409:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: Revision, state or idempotency conflict.
      headers:
        X-Request-ID:
          description: Gateway request ID for Activity and support.
          schema:
            type: string
            format: uuid
    Api413:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: JSON body exceeds the gateway size limit.
      headers:
        X-Request-ID:
          description: Gateway request ID for Activity and support.
          schema:
            type: string
            format: uuid
    Api415:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: Send application/json.
      headers:
        X-Request-ID:
          description: Gateway request ID for Activity and support.
          schema:
            type: string
            format: uuid
    Api422:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: Provider request validation failed.
      headers:
        X-Request-ID:
          description: Gateway request ID for Activity and support.
          schema:
            type: string
            format: uuid
    Api429:
      headers:
        X-Request-ID:
          description: Gateway request ID for Activity and support.
          schema:
            type: string
            format: uuid
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: Request rate or concurrency exceeded.
    Api500:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: Unexpected gateway failure.
      headers:
        X-Request-ID:
          description: Gateway request ID for Activity and support.
          schema:
            type: string
            format: uuid
    Api501:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: The backend does not implement this option.
      headers:
        X-Request-ID:
          description: Gateway request ID for Activity and support.
          schema:
            type: string
            format: uuid
    Api502:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: Backend request failed.
      headers:
        X-Request-ID:
          description: Gateway request ID for Activity and support.
          schema:
            type: string
            format: uuid
    Api503:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      description: A required service or configuration is unavailable.
      headers:
        X-Request-ID:
          description: Gateway request ID for Activity and support.
          schema:
            type: string
            format: uuid
    Api504:
      description: Inference deadline exceeded.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    customerKey:
      type: http
      scheme: bearer
      bearerFormat: lk_...
      description: >-
        Project customer key. Requires the permission for the requested
        endpoint.
    customerHeaderKey:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        Alternative project-key header. Authorization takes precedence when both
        are supplied.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.