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

# Chat Completions

> Tokenless accepts the compatible Chat Completions request shape and
routes the request behind a Tokenless routing profile. For the complete
upstream contract, see the [OpenAI API reference](https://developers.openai.com/api/reference/overview).


<div className="endpoint-signature"><span className="endpoint-method endpoint-method-post">POST</span><code>/openai/v1/chat/completions</code></div>

For the full upstream contract, see the [OpenAI API reference](https://developers.openai.com/api/reference/overview).

<RequestExample>
  ```bash cURL
  curl https://api.usetokenless.com/openai/v1/chat/completions \
    -H "Authorization: Bearer $TOKENLESS_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "tokenless-pro",
      "messages": [
        {"role": "user", "content": "Explain model routing in one paragraph."}
      ],
      "stream": true
    }'
  ```
</RequestExample>

<ResponseExample>
  ```sse Stream (abridged)
  data: {"id":"chatcmpl_req_1e6255bf_5d10049d4ab0_1","object":"chat.completion.chunk","created":0,"model":"tokenless-pro","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}

  data: {"id":"chatcmpl_req_1e6255bf_5d10049d4ab0_1","object":"chat.completion.chunk","created":0,"model":"tokenless-pro","choices":[{"index":0,"delta":{"content":"Model routing is the process of directing a request to the most suitable model…"},"finish_reason":null}]}

  data: {"id":"chatcmpl_req_1e6255bf_5d10049d4ab0_1","object":"chat.completion.chunk","created":0,"model":"tokenless-pro","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

  data: {"id":"chatcmpl_req_1e6255bf_5d10049d4ab0_1","object":"chat.completion.chunk","created":0,"model":"tokenless-pro","choices":[],"usage":{"prompt_tokens":11,"completion_tokens":227,"total_tokens":238}}

  data: [DONE]
  ```
</ResponseExample>


## OpenAPI

````yaml /openapi/compatibility.yaml post /openai/v1/chat/completions
openapi: 3.1.0
info:
  title: Tokenless Compatibility and BYOK API
  version: 1.0.0
  description: |
    OpenAI- and Anthropic-compatible routing endpoints, plus interactive-session
    management for bring-your-own provider keys.
servers:
  - url: https://api.usetokenless.com
security:
  - tokenlessBearer: []
paths:
  /openai/v1/chat/completions:
    post:
      tags:
        - OpenAI
      summary: Chat Completions
      description: >
        Tokenless accepts the compatible Chat Completions request shape and

        routes the request behind a Tokenless routing profile. For the complete

        upstream contract, see the [OpenAI API
        reference](https://developers.openai.com/api/reference/overview).
      operationId: createChatCompletion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OpenAIChatRequest'
      responses:
        '200':
          description: An OpenAI-compatible completion response or SSE stream.
          headers:
            X-Request-Id:
              $ref: '#/components/headers/RequestID'
        '400':
          $ref: '#/components/responses/OpenAIError'
        '401':
          $ref: '#/components/responses/OpenAIError'
        '402':
          $ref: '#/components/responses/OpenAIError'
components:
  schemas:
    OpenAIChatRequest:
      type: object
      required:
        - model
        - messages
      properties:
        model:
          $ref: '#/components/schemas/RoutingProfile'
        messages:
          type: array
          minItems: 1
          items:
            type: object
            additionalProperties: true
        stream:
          type: boolean
          default: false
      additionalProperties: true
    RoutingProfile:
      type: string
      enum:
        - tokenless-pro
        - tokenless-max
        - tokenless-ultra-saver
    OpenAIError:
      type: object
      properties:
        error:
          type: object
          additionalProperties: true
  headers:
    RequestID:
      description: Identifier for the routed request. Save it for support and usage lookup.
      schema:
        type: string
  responses:
    OpenAIError:
      description: OpenAI-compatible error response.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/OpenAIError'
  securitySchemes:
    tokenlessBearer:
      type: http
      scheme: bearer
      bearerFormat: Tokenless API key

````