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

# Create a chat completion

> Creates a chat completion. Set stream: true for server-sent events.



## OpenAPI

````yaml https://api.abliteration.ai/openapi.json post /v1/chat/completions
openapi: 3.0.3
info:
  title: abliteration.ai API
  version: '2026-04-14'
  description: >-
    OpenAI-compatible chat completions and responses APIs for abliteration.ai,
    plus Anthropic-compatible messages and Policy Gateway endpoints for
    enforcement, config, simulations, and audits.
  termsOfService: https://abliteration.ai/terms-of-service
  contact:
    email: help@abliteration.ai
servers:
  - url: https://api.abliteration.ai
    description: Production
  - url: http://localhost:8080
    description: Local development
security: []
tags:
  - name: Chat Completions
    description: OpenAI-compatible chat completions.
  - name: Responses
    description: OpenAI-compatible Responses API.
  - name: Policy Gateway
    description: Policy-enforced chat completions.
  - name: Anthropic Messages
    description: Anthropic-compatible Messages API.
  - name: Models
    description: OpenAI-compatible model listing.
paths:
  /v1/chat/completions:
    post:
      tags:
        - Chat Completions
      summary: Create a chat completion
      description: 'Creates a chat completion. Set stream: true for server-sent events.'
      operationId: createChatCompletion
      parameters:
        - name: X-Free-Tier
          in: header
          description: Set to true to use the single anonymous free request.
          required: false
          schema:
            type: string
            enum:
              - 'true'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
            examples:
              basic:
                summary: Basic request
                value:
                  model: abliterated-model
                  messages:
                    - role: user
                      content: Write one sentence about Stonehenge.
                  temperature: 0.7
                  max_tokens: 128
              streaming:
                summary: Streaming request
                value:
                  model: abliterated-model
                  messages:
                    - role: user
                      content: Stream a short greeting.
                  stream: true
      responses:
        '200':
          description: Chat completion response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
              examples:
                success:
                  summary: 200 OK
                  value:
                    id: chatcmpl-abc123
                    object: chat.completion
                    created: 1735958400
                    model: abliterated-model
                    choices:
                      - index: 0
                        message:
                          role: assistant
                          content: Hello there. How can I help?
                        finish_reason: stop
                    usage:
                      prompt_tokens: 12
                      completion_tokens: 8
                      total_tokens: 20
                    remaining_credits: 48
                    estimated_credits_used: 1
                    estimated_cost_usd: 0.000105
            text/event-stream:
              schema:
                type: string
                description: Streaming response as server-sent events.
              examples:
                stream:
                  summary: SSE stream
                  value: >
                    data:
                    {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1735958400,"model":"abliterated-model","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}


                    data:
                    {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1735958400,"model":"abliterated-model","choices":[{"index":0,"delta":{"content":"Hello!"},"finish_reason":null}]}


                    data: [DONE]
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Insufficient credits
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: Upstream unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - BearerAuth: []
components:
  schemas:
    ChatCompletionRequest:
      type: object
      required:
        - model
        - messages
      properties:
        model:
          type: string
          description: Model id.
        messages:
          type: array
          description: >-
            Conversation messages. content can be a string or a list of parts
            for multimodal requests.
          items:
            $ref: '#/components/schemas/ChatMessage'
        temperature:
          type: number
          minimum: 0
          maximum: 2
          description: Sampling temperature.
        top_p:
          type: number
          minimum: 0
          maximum: 1
        'n':
          type: integer
          minimum: 1
        stream:
          type: boolean
          default: false
        max_tokens:
          type: integer
          minimum: 1
        stop:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        presence_penalty:
          type: number
          minimum: -2
          maximum: 2
        frequency_penalty:
          type: number
          minimum: -2
          maximum: 2
        user:
          type: string
          description: End-user identifier for abuse monitoring.
        flagged_categories:
          type: array
          description: >-
            Optional moderation categories to block for this request. Supported:
            harassment, hate, illicit, sexual. Self-harm and sexual/minors are
            always blocked.
          items:
            type: string
    ChatCompletionResponse:
      type: object
      required:
        - id
        - object
        - created
        - model
        - choices
      properties:
        id:
          type: string
        object:
          type: string
          enum:
            - chat.completion
        created:
          type: integer
        model:
          type: string
        choices:
          type: array
          items:
            $ref: '#/components/schemas/ChatCompletionChoice'
        usage:
          $ref: '#/components/schemas/Usage'
        remaining_credits:
          type: integer
          nullable: true
        estimated_credits_used:
          type: integer
        estimated_cost_usd:
          type: number
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
        code:
          type: string
    ChatMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - system
            - user
            - assistant
            - tool
        content:
          description: Text content or an array of text/image_url parts.
          oneOf:
            - type: string
            - type: array
              items:
                $ref: '#/components/schemas/ContentPart'
        name:
          type: string
    ChatCompletionChoice:
      type: object
      required:
        - index
        - message
        - finish_reason
      properties:
        index:
          type: integer
        message:
          $ref: '#/components/schemas/ChatMessageResponse'
        finish_reason:
          type: string
          nullable: true
    Usage:
      type: object
      properties:
        prompt_tokens:
          type: integer
        completion_tokens:
          type: integer
        total_tokens:
          type: integer
    ContentPart:
      oneOf:
        - $ref: '#/components/schemas/TextContentPart'
        - $ref: '#/components/schemas/ImageContentPart'
    ChatMessageResponse:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - assistant
        content:
          type: string
    TextContentPart:
      type: object
      required:
        - type
        - text
      properties:
        type:
          type: string
          enum:
            - text
        text:
          type: string
    ImageContentPart:
      type: object
      required:
        - type
        - image_url
      properties:
        type:
          type: string
          enum:
            - image_url
        image_url:
          $ref: '#/components/schemas/ImageUrl'
    ImageUrl:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          format: uri
        detail:
          type: string
          enum:
            - low
            - high
            - auto
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Use a JWT or abliteration.ai API key as a Bearer token.

````