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

# OpenAI Chat

> Interface description: Compatible endpoint of OpenAI Chat Completions API, supports `stream` streaming output. The request, response and error formats fully comply with the OpenAI specifications; authentication uses `Authorization: Bearer <API Key>` (included by OpenAI SDK by default). Existing OpenAI SDK or ecological tools only need to replace the baseURL and API Key to access, and billing is based on AiToEarn points.

Before calling this interface, please request the ["Conversation Model List"](/en/api-reference/get-api-ai-models-chat) interface (`GET /api/ai/models/chat`) to obtain the currently available model list.



## OpenAPI

````yaml /openapi/en/aitoearn.openapi.json post /api/ai/chat/completions
openapi: 3.0.1
info:
  title: AiToEarn Open Platform API
  description: >-
    AiToEarn Open Platform API. You can switch between the China and
    international sites for testing. Business success is determined by whether
    the response body has code === 0.
  version: 1.0.0
  contact: {}
servers:
  - url: https://aitoearn.cn
    description: China site
  - url: https://aitoearn.ai
    description: International site
security: []
tags:
  - name: AI Services
  - name: AI Services/Video Generation
  - name: AI Services/Image Generation
  - name: Channel Management
  - name: Channel Management/Accounts
  - name: Channel Management/Publishing
  - name: Channel Management/Platforms
  - name: Channel Management/Works
  - name: Channel Management/Account Groups
  - name: Channel Management/Authorization
  - name: Asset Management
  - name: AI Services/Large Language Models
paths:
  /api/ai/chat/completions:
    post:
      tags:
        - AI Services/Large Language Models
      summary: OpenAI Chat
      description: >-
        Interface description: Compatible endpoint of OpenAI Chat Completions
        API, supports `stream` streaming output. The request, response and error
        formats fully comply with the OpenAI specifications; authentication uses
        `Authorization: Bearer <API Key>` (included by OpenAI SDK by default).
        Existing OpenAI SDK or ecological tools only need to replace the baseURL
        and API Key to access, and billing is based on AiToEarn points.


        Before calling this interface, please request the ["Conversation Model
        List"](/en/api-reference/get-api-ai-models-chat) interface (`GET
        /api/ai/models/chat`) to obtain the currently available model list.
      operationId: RelayController_chatCompletions
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RelayChatCompletionsDto'
            examples: {}
        required: true
      responses:
        '200':
          description: >-
            Native third-party protocol response or SSE data, not wrapped in the
            AiToEarn common response envelope.
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
                description: >-
                  Native third-party protocol response, not wrapped in the
                  AiToEarn common response envelope.
              examples:
                success:
                  summary: Native third-party success response
                  value:
                    id: RelayController_chatCompletions_example
                    object: response
            text/event-stream:
              schema:
                type: string
                description: SSE streaming response.
      deprecated: false
      security:
        - apikey-header-Authorization: []
components:
  schemas:
    RelayChatCompletionsDto:
      type: object
      properties:
        messages:
          minItems: 1
          type: array
          items:
            type: object
            properties:
              role:
                type: string
                description: Message role, used to distinguish different message sources
              content:
                description: Content text
            required:
              - role
              - content
            additionalProperties: true
          description: Message list
        model:
          type: string
          description: >-
            Model ID. First call the ["Conversation Model
            List"](/en/api-reference/get-api-ai-models-chat) interface (`GET
            /api/ai/models/chat`) and pass in the `data[n].name` returned by it.
        stream:
          description: Whether to stream the return
          type: boolean
      required:
        - messages
        - model
      additionalProperties: true
  securitySchemes:
    apikey-header-Authorization:
      type: apiKey
      in: header
      name: Authorization
      description: 'Used by OpenAI-compatible endpoints. Example: Bearer <token>.'

````