> ## 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.

# チャット補完を作成

> OpenAI 互換の Chat Completions エンドポイント。現在は非ストリーミング呼び出しが中心です。



## OpenAPI

````yaml /ja/openapi.json post /v1/chat/completions
openapi: 3.1.0
info:
  title: APIAny.AI 公開 API
  version: 1.0.0
  description: APIAny.AI のモデル統合、非同期メディアタスク、チャット生成、クレジット照会、タスク照会のための公開 API。
servers:
  - url: https://apiany.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Models
    description: 公開モデルカタログ。
  - name: Chat
    description: テキスト生成およびチャット互換エンドポイント。
  - name: Images
    description: 画像生成および画像編集エンドポイント。
  - name: Videos
    description: 動画生成エンドポイント。
  - name: Moderation
    description: Image safety and moderation endpoints.
  - name: Tasks
    description: 非同期タスク照会。
  - name: Account
    description: アカウントおよびクレジットの照会。
  - name: Free APIs
    description: Free utility APIs protected by API key rate limits.
paths:
  /v1/chat/completions:
    post:
      tags:
        - Chat
      summary: チャット補完を作成
      description: OpenAI 互換の Chat Completions エンドポイント。現在は非ストリーミング呼び出しが中心です。
      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 互換のチャット補完レスポンス。
          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: サンプリング温度。
        top_p:
          type: number
          minimum: 0
          maximum: 1
          description: 核サンプリングの累積確率。
        max_tokens:
          type: integer
          minimum: 1
          description: レスポンスの最大トークン数。
        stop:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
          description: 最大 4 個の停止シーケンス。
        'n':
          type: integer
          minimum: 1
          description: 生成する候補数。
        frequency_penalty:
          type: number
          minimum: -2
          maximum: 2
        presence_penalty:
          type: number
          minimum: -2
          maximum: 2
        seed:
          type: integer
          description: できる限り再現可能なサンプリングシード。
        response_format:
          type: object
          description: 'JSON オブジェクトまたは JSON Schema 出力を強制します（例: { "type": "json_object" }）。'
          additionalProperties: true
        tools:
          type: array
          description: モデルが呼び出せるツール／関数の宣言。
          items:
            type: object
            additionalProperties: true
        tool_choice:
          description: >-
            ツール選択: '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: リスク監査のためのエンドユーザー識別子。
        stream:
          type: boolean
          description: >-
            true の場合、増分を SSE でストリーミング返却します（OpenAI chat.completion.chunk）。'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
      required:
        - role
        - content
    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: リクエストパラメータが無効です。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: API Key が指定されていないか、API Key が無効です。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    RateLimited:
      description: リクエストがレート制限を超えました。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key

````