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

# Create a chat completion

> Proxies an OpenAI-compatible request to an eligible provider and meters the response.



## OpenAPI

````yaml /gateway-reference/openapi.yaml post /v1/chat/completions
openapi: 3.1.0
info:
  title: Tulip Gateway API
  version: 2.0.0
  description: >-
    Offer-aware model discovery, quotes, OpenAI-compatible inference, provider
    onboarding, and settlement for Tulip v1 model markets.
servers: []
security: []
tags:
  - name: Service
  - name: Models
  - name: Inference
  - name: Providers
  - name: Settlement
paths:
  /v1/chat/completions:
    post:
      tags:
        - Inference
      summary: Create a chat completion
      description: >-
        Proxies an OpenAI-compatible request to an eligible provider and meters
        the response.
      operationId: createChatCompletion
      parameters:
        - name: X-Tulip-Permit
          in: header
          required: true
          schema:
            $ref: '#/components/schemas/Hex32'
        - name: X-Tulip-Quote
          in: header
          required: false
          schema:
            $ref: '#/components/schemas/Hex32'
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatRequest'
      responses:
        '200':
          description: Upstream OpenAI-compatible JSON or server-sent event stream.
          headers:
            X-Tulip-Request-Id:
              schema:
                $ref: '#/components/schemas/Hex32'
            X-Tulip-Quote-Id:
              schema:
                $ref: '#/components/schemas/Hex32'
            X-Tulip-Offer-Id:
              schema:
                $ref: '#/components/schemas/Hex32'
            X-Tulip-Tariff-Version:
              schema:
                type: string
            X-Tulip-Credits-Charged:
              schema:
                type: string
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
            text/event-stream:
              schema:
                type: string
        '402':
          $ref: '#/components/responses/Error'
        '409':
          $ref: '#/components/responses/Error'
        '503':
          $ref: '#/components/responses/Error'
      security:
        - TulipApiKey: []
components:
  schemas:
    Hex32:
      type: string
      pattern: ^0x[0-9a-fA-F]{64}$
    ChatRequest:
      type: object
      properties:
        model:
          type: string
        offer:
          $ref: '#/components/schemas/Hex32'
        messages:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/ChatMessage'
        max_tokens:
          type: integer
          minimum: 1
        max_completion_tokens:
          type: integer
          minimum: 1
        temperature:
          type: number
        top_p:
          type: number
        stop:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        stream:
          type: boolean
        tools:
          type: array
          items: {}
        tool_choice: {}
        response_format: {}
        seed:
          type: integer
        user:
          type: string
      required:
        - model
        - messages
      additionalProperties: true
    ChatMessage:
      type: object
      properties:
        role:
          type: string
          enum:
            - system
            - developer
            - user
            - assistant
            - tool
            - function
        content: {}
      required:
        - role
        - content
      additionalProperties: true
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
            type:
              type: string
            message:
              type: string
          required:
            - code
            - type
            - message
      required:
        - error
  responses:
    Error:
      description: Tulip error response.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    TulipApiKey:
      type: http
      scheme: bearer
      bearerFormat: Tulip API key

````