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

# Create Playground Chat Completion



## OpenAPI

````yaml /openapi.json post /v1/playground/{playground_token}/chat/completions
openapi: 3.1.0
info:
  title: Trajectory API
  version: 0.1.0
servers:
  - url: https://api.trajectory.ai
security: []
paths:
  /v1/playground/{playground_token}/chat/completions:
    post:
      tags:
        - inference
      summary: Create Playground Chat Completion
      operationId: createPlaygroundChatCompletion
      parameters:
        - name: playground_token
          in: path
          required: true
          schema:
            type: string
            title: Playground Token
        - name: X-API-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Api-Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InferenceErrorEnvelope'
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InferenceErrorEnvelope'
          description: Unauthorized
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InferenceErrorEnvelope'
          description: Not Found
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InferenceErrorEnvelope'
          description: Too Many Requests
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InferenceErrorEnvelope'
          description: Internal Server Error
        '502':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InferenceErrorEnvelope'
          description: Bad Gateway
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InferenceErrorEnvelope'
          description: Service Unavailable
      security:
        - InferenceAuthorization: []
components:
  schemas:
    ChatCompletionRequest:
      properties:
        model:
          type: string
          title: Model
        messages:
          items:
            $ref: '#/components/schemas/ChatMessage'
          type: array
          title: Messages
        stream:
          type: boolean
          title: Stream
          default: false
        temperature:
          anyOf:
            - type: number
            - type: 'null'
          title: Temperature
        max_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Max Tokens
        top_p:
          anyOf:
            - type: number
            - type: 'null'
          title: Top P
      additionalProperties: true
      type: object
      required:
        - model
        - messages
      title: ChatCompletionRequest
    ChatCompletionResponse:
      properties:
        id:
          type: string
          title: Id
        object:
          type: string
          title: Object
        created:
          type: integer
          title: Created
        model:
          type: string
          title: Model
        choices:
          items:
            $ref: '#/components/schemas/ChatCompletionChoice'
          type: array
          title: Choices
        usage:
          anyOf:
            - $ref: '#/components/schemas/Usage'
            - type: 'null'
      additionalProperties: true
      type: object
      required:
        - id
        - object
        - created
        - model
        - choices
      title: ChatCompletionResponse
    InferenceErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/InferenceErrorDetail'
      type: object
      required:
        - error
      title: InferenceErrorEnvelope
    ChatMessage:
      properties:
        role:
          type: string
          title: Role
        content:
          anyOf:
            - type: string
            - items:
                additionalProperties: true
                type: object
              type: array
            - type: 'null'
          title: Content
      additionalProperties: true
      type: object
      required:
        - role
      title: ChatMessage
    ChatCompletionChoice:
      properties:
        index:
          type: integer
          title: Index
        message:
          $ref: '#/components/schemas/ChatCompletionResponseMessage'
        finish_reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Finish Reason
      additionalProperties: true
      type: object
      required:
        - index
        - message
      title: ChatCompletionChoice
    Usage:
      properties:
        prompt_tokens:
          type: integer
          title: Prompt Tokens
        completion_tokens:
          type: integer
          title: Completion Tokens
        total_tokens:
          type: integer
          title: Total Tokens
      additionalProperties: true
      type: object
      required:
        - prompt_tokens
        - completion_tokens
        - total_tokens
      title: Usage
    InferenceErrorDetail:
      properties:
        message:
          type: string
          title: Message
        type:
          type: string
          title: Type
        param:
          anyOf:
            - type: string
            - type: 'null'
          title: Param
        code:
          anyOf:
            - type: string
            - type: 'null'
          title: Code
      type: object
      required:
        - message
        - type
      title: InferenceErrorDetail
    ChatCompletionResponseMessage:
      properties:
        role:
          type: string
          title: Role
        content:
          anyOf:
            - type: string
            - type: 'null'
          title: Content
      additionalProperties: true
      type: object
      required:
        - role
        - content
      title: ChatCompletionResponseMessage
  securitySchemes:
    InferenceAuthorization:
      type: http
      scheme: bearer

````