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

# Use the ScholarAI Agent to generate chat completions

> Mimics the input and output to the OpenAI Chat Completion API: https://platform.openai.com/docs/api-reference/chat/create



## OpenAPI

````yaml post /api/chat/completions
openapi: 3.1.0
info:
  title: No title
  version: No version
servers:
  - url: https://api.scholarai.io
security:
  - ApiKeyAuth: []
tags:
  - name: Api
paths:
  /api/chat/completions:
    post:
      tags:
        - Api
      summary: Use the ScholarAI Agent to generate chat completions
      description: >-
        Mimics the input and output to the OpenAI Chat Completion API:
        https://platform.openai.com/docs/api-reference/chat/create
      operationId: api_chat_completions
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                model:
                  type: string
                  description: >-
                    Model being used. Currently ignored and defaults to
                    "scholarai" with GPT4-turbo
                messages:
                  type: array
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        description: Role of the message. Must be "user"
                      content:
                        type: string
                        description: Content of the message. Must be a string.
                stream:
                  type: boolean
                  description: >-
                    Whether or not to stream the response. Streaming is
                    recommended!
      responses:
        '200':
          description: Stream based on OpenAI Completions structure
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      name: x-scholarai-api-key
      in: header

````