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

# Create a chat completion



## OpenAPI

````yaml /api/openapi.json post /v1/chat/completions
openapi: 3.1.0
info:
  title: Prism API
  version: 1.0.0
  description: >-
    OpenAI-compatible chat, embeddings, image, and asynchronous video APIs with
    Prism billing and policy controls.
servers:
  - url: https://api.prismgateway.io
    description: Production
security: []
paths:
  /v1/chat/completions:
    post:
      tags:
        - Chat
      summary: Create a chat completion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              additionalProperties: true
              type: object
              required:
                - model
                - messages
              properties:
                model:
                  minLength: 1
                  maxLength: 256
                  type: string
                messages:
                  minItems: 1
                  type: array
                  items:
                    additionalProperties: true
                    type: object
                    required:
                      - role
                    properties:
                      role:
                        type: string
                        enum:
                          - system
                          - user
                          - assistant
                          - tool
                      content:
                        anyOf:
                          - type: string
                          - type: array
                            items: {}
                      tool_calls:
                        type: array
                        items: {}
                      name:
                        type: string
                      tool_call_id:
                        type: string
                stream:
                  type: boolean
                temperature:
                  minimum: 0
                  maximum: 2
                  type: number
                max_tokens:
                  minimum: 1
                  anyOf:
                    - format: integer
                      default: 0
                      type: string
                    - type: integer
                      minimum: 1
                top_p:
                  minimum: 0
                  maximum: 1
                  type: number
                frequency_penalty:
                  minimum: -2
                  maximum: 2
                  type: number
                presence_penalty:
                  minimum: -2
                  maximum: 2
                  type: number
                tools:
                  type: array
                  items: {}
                tool_choice:
                  anyOf:
                    - type: string
                    - {}
                user:
                  type: string
                response_format: {}
                seed:
                  anyOf:
                    - format: integer
                      default: 0
                      type: string
                    - type: integer
                logprobs:
                  type: boolean
                top_logprobs:
                  minimum: 0
                  maximum: 20
                  anyOf:
                    - format: integer
                      default: 0
                      type: string
                    - minimum: 0
                      maximum: 20
                      type: integer
                'n':
                  minimum: 1
                  maximum: 128
                  anyOf:
                    - format: integer
                      default: 0
                      type: string
                    - minimum: 1
                      maximum: 128
                      type: integer
                stop:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
          application/x-www-form-urlencoded:
            schema:
              additionalProperties: true
              type: object
              required:
                - model
                - messages
              properties:
                model:
                  minLength: 1
                  maxLength: 256
                  type: string
                messages:
                  minItems: 1
                  type: array
                  items:
                    additionalProperties: true
                    type: object
                    required:
                      - role
                    properties:
                      role:
                        type: string
                        enum:
                          - system
                          - user
                          - assistant
                          - tool
                      content:
                        anyOf:
                          - type: string
                          - type: array
                            items: {}
                      tool_calls:
                        type: array
                        items: {}
                      name:
                        type: string
                      tool_call_id:
                        type: string
                stream:
                  type: boolean
                temperature:
                  minimum: 0
                  maximum: 2
                  type: number
                max_tokens:
                  minimum: 1
                  anyOf:
                    - format: integer
                      default: 0
                      type: string
                    - type: integer
                      minimum: 1
                top_p:
                  minimum: 0
                  maximum: 1
                  type: number
                frequency_penalty:
                  minimum: -2
                  maximum: 2
                  type: number
                presence_penalty:
                  minimum: -2
                  maximum: 2
                  type: number
                tools:
                  type: array
                  items: {}
                tool_choice:
                  anyOf:
                    - type: string
                    - {}
                user:
                  type: string
                response_format: {}
                seed:
                  anyOf:
                    - format: integer
                      default: 0
                      type: string
                    - type: integer
                logprobs:
                  type: boolean
                top_logprobs:
                  minimum: 0
                  maximum: 20
                  anyOf:
                    - format: integer
                      default: 0
                      type: string
                    - minimum: 0
                      maximum: 20
                      type: integer
                'n':
                  minimum: 1
                  maximum: 128
                  anyOf:
                    - format: integer
                      default: 0
                      type: string
                    - minimum: 1
                      maximum: 128
                      type: integer
                stop:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
          multipart/form-data:
            schema:
              additionalProperties: true
              type: object
              required:
                - model
                - messages
              properties:
                model:
                  minLength: 1
                  maxLength: 256
                  type: string
                messages:
                  minItems: 1
                  type: array
                  items:
                    additionalProperties: true
                    type: object
                    required:
                      - role
                    properties:
                      role:
                        type: string
                        enum:
                          - system
                          - user
                          - assistant
                          - tool
                      content:
                        anyOf:
                          - type: string
                          - type: array
                            items: {}
                      tool_calls:
                        type: array
                        items: {}
                      name:
                        type: string
                      tool_call_id:
                        type: string
                stream:
                  type: boolean
                temperature:
                  minimum: 0
                  maximum: 2
                  type: number
                max_tokens:
                  minimum: 1
                  anyOf:
                    - format: integer
                      default: 0
                      type: string
                    - type: integer
                      minimum: 1
                top_p:
                  minimum: 0
                  maximum: 1
                  type: number
                frequency_penalty:
                  minimum: -2
                  maximum: 2
                  type: number
                presence_penalty:
                  minimum: -2
                  maximum: 2
                  type: number
                tools:
                  type: array
                  items: {}
                tool_choice:
                  anyOf:
                    - type: string
                    - {}
                user:
                  type: string
                response_format: {}
                seed:
                  anyOf:
                    - format: integer
                      default: 0
                      type: string
                    - type: integer
                logprobs:
                  type: boolean
                top_logprobs:
                  minimum: 0
                  maximum: 20
                  anyOf:
                    - format: integer
                      default: 0
                      type: string
                    - minimum: 0
                      maximum: 20
                      type: integer
                'n':
                  minimum: 1
                  maximum: 128
                  anyOf:
                    - format: integer
                      default: 0
                      type: string
                    - minimum: 1
                      maximum: 128
                      type: integer
                stop:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
      responses:
        '200':
          description: OpenAI-compatible chat completion or server-sent event stream.
          headers:
            x-prism-trace-id:
              description: Prism request ID for support and usage lookup.
              schema:
                type: string
            x-prism-cost-credits:
              description: Charged amount in minor credits when available.
              schema:
                type: integer
                minimum: 0
            x-prism-cache:
              description: Whether the response was served from Prism's response cache.
              schema:
                type: string
                enum:
                  - HIT
                  - MISS
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
            text/event-stream:
              schema:
                type: string
        '400':
          description: Invalid request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrismErrorResponse'
        '401':
          description: Missing, malformed, unknown, or revoked API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrismErrorResponse'
        '402':
          description: Credits, reservation, or organization budget prevents admission.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrismErrorResponse'
        '403':
          description: Trial, key, model, or organization policy denied the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrismErrorResponse'
        '404':
          description: The requested model was not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrismErrorResponse'
        '413':
          description: Request body exceeds the configured size limit.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrismErrorResponse'
        '429':
          description: Rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrismErrorResponse'
        '500':
          description: Prism or an upstream provider could not complete the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrismErrorResponse'
        '502':
          description: An upstream provider returned an invalid or failed response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrismErrorResponse'
        '503':
          description: The selected model or runtime is temporarily unavailable.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrismErrorResponse'
        default:
          description: The request could not be completed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PrismErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    PrismErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
          properties:
            type:
              type: string
            code:
              type: string
            message:
              type: string
            action:
              type: string
              enum:
                - top_up
                - contact_org_admin
            help_url:
              type: string
              format: uri
            allowed_models:
              type: array
              items:
                type: string
          additionalProperties: true
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Prism API key
      description: Prism API key beginning with sk-prism-

````