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

# Create chat completion

> OpenAI-compatible chat completion endpoint. Streaming support is reserved for a future capability.



## OpenAPI

````yaml /openapi.json post /v1/chat/completions
openapi: 3.1.0
info:
  title: APIAny.AI Public API
  version: 1.0.0
  description: >-
    Public API for APIAny.AI model aggregation, async media tasks, chat
    completions, billing visibility, and task lookup.
servers:
  - url: https://apiany.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Models
    description: Public model catalog.
  - name: Chat
    description: Text generation and chat-compatible endpoints.
  - name: Images
    description: Image generation and editing endpoints.
  - name: Videos
    description: Video generation endpoints.
  - name: Moderation
    description: Image safety and moderation endpoints.
  - name: Tasks
    description: Async task lookup.
  - name: Account
    description: Account and credit visibility.
  - name: Free APIs
    description: Free utility APIs protected by API key rate limits.
paths:
  /v1/chat/completions:
    post:
      tags:
        - Chat
      summary: Create chat completion
      description: >-
        OpenAI-compatible chat completion endpoint. Streaming support is
        reserved for a future capability.
      operationId: createChatCompletion
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
            examples:
              basic:
                value:
                  model: gpt-5.4
                  messages:
                    - role: user
                      content: Write a concise product tagline for APIAny.AI.
                  temperature: 0.7
      responses:
        '200':
          description: OpenAI-compatible chat completion.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  schemas:
    ChatCompletionRequest:
      type: object
      properties:
        model:
          type: string
          example: gpt-5.4
        messages:
          type: array
          items:
            $ref: '#/components/schemas/ChatMessage'
        temperature:
          type: number
          minimum: 0
          maximum: 2
          description: Sampling temperature.
        top_p:
          type: number
          minimum: 0
          maximum: 1
          description: Nucleus sampling probability mass.
        max_tokens:
          type: integer
          minimum: 1
          deprecated: true
          description: >-
            Deprecated compatibility alias for max_completion_tokens. APIAny
            converts it only when the selected model route requires the newer
            field.
        max_completion_tokens:
          type: integer
          minimum: 1
          maximum: 1048576
          description: >-
            Maximum reasoning plus final-answer tokens. Kimi K3 defaults to
            131072 when omitted and supports up to 1048576.
        reasoning_effort:
          type: string
          enum:
            - max
          description: >-
            Kimi K3 reasoning effort. K3 always reasons and currently supports
            only max.
        stop:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
          description: Up to 4 stop sequences.
        'n':
          type: integer
          minimum: 1
          description: Number of completions to generate.
        frequency_penalty:
          type: number
          minimum: -2
          maximum: 2
        presence_penalty:
          type: number
          minimum: -2
          maximum: 2
        seed:
          type: integer
          description: Best-effort deterministic sampling seed.
        response_format:
          type: object
          description: >-
            Force JSON object or JSON-schema output, e.g. { "type":
            "json_object" }.
          additionalProperties: true
        tools:
          type: array
          description: Tool / function declarations the model may call.
          items:
            type: object
            additionalProperties: true
        tool_choice:
          description: >-
            Tool selection: 'auto' | 'none' | 'required' | { type: 'function',
            function: { name } }.
          oneOf:
            - type: string
            - type: object
              additionalProperties: true
        logprobs:
          type: boolean
        top_logprobs:
          type: integer
          minimum: 0
          maximum: 20
        logit_bias:
          type: object
          additionalProperties: true
        user:
          type: string
          description: End-user identifier for abuse monitoring.
        stream:
          type: boolean
          description: >-
            If true, partial deltas are streamed as server-sent events (OpenAI
            chat.completion.chunk), terminated by 'data: [DONE]'.
      required:
        - model
        - messages
    ChatCompletionResponse:
      type: object
      properties:
        id:
          type: string
        object:
          type: string
          example: chat.completion
        created:
          type: integer
        model:
          type: string
        choices:
          type: array
          items:
            type: object
            additionalProperties: true
        usage:
          $ref: '#/components/schemas/TokenUsage'
      required:
        - id
        - object
        - created
        - model
        - choices
    ChatMessage:
      type: object
      properties:
        role:
          type: string
          enum:
            - system
            - user
            - assistant
            - tool
        content:
          oneOf:
            - type: string
            - type: array
              items:
                type: object
                additionalProperties: true
        reasoning_content:
          type: string
          description: >-
            Reasoning trace returned by supported thinking models. Preserve it
            in Kimi K3 assistant-message history.
        partial:
          type: boolean
          default: false
          description: >-
            Kimi partial mode. Set true only on the final assistant prefix
            message.
        tools:
          type: array
          description: >-
            Kimi K3 dynamic tool declarations carried by a content-less system
            message.
          items:
            type: object
            additionalProperties: true
      required:
        - role
    TokenUsage:
      type: object
      properties:
        prompt_tokens:
          type: integer
        completion_tokens:
          type: integer
        total_tokens:
          type: integer
        input_tokens:
          type: integer
        output_tokens:
          type: integer
        cached_input_tokens:
          type: integer
      additionalProperties: true
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              type: string
              enum:
                - invalid_request
                - auth_error
                - rate_limit
                - insufficient_quota
                - content_policy
                - timeout
                - network_error
                - service_error
                - billable_error
                - unknown
            message:
              type: string
            param:
              type:
                - string
                - 'null'
            code:
              type:
                - string
                - 'null'
          required:
            - type
            - message
      required:
        - error
  responses:
    BadRequest:
      description: Invalid request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    RateLimited:
      description: Rate limit exceeded.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key

````