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

# Create a chat completion

> Send text to your personal Eigi using the Chat Completions format.

Send at least one message and a user turn. The reply is in `choices[0].message.content`. For a continuing conversation, either send its full history on each request or send a stable `X-Eigi-Session-Id` and only the next turn.

For streamed output, set `stream` to true and read server-sent events through `[DONE]`. Set `stream_options.include_usage` to true for a trailing usage chunk. [Client setup and examples](https://docs.eigi.ai/eigi-agent/developer-api.md).


## OpenAPI

````yaml api-reference/openapi.json POST /v1/eigi-agent/openai/chat/completions
openapi: 3.0.0
info:
  title: eigi.ai API
  description: REST API for managing AI voice agents and conversations
  version: 1.0.0
  contact:
    email: buddy@eigi.ai
    url: https://eigi.ai
servers:
  - url: https://api.eigi.ai
    description: Production server
security:
  - ApiKeyAuth: []
  - OAuthAccessToken: []
paths:
  /v1/eigi-agent/openai/chat/completions:
    post:
      tags:
        - Personal agent
      summary: Create a chat completion
      description: Send text to your personal Eigi using the Chat Completions format.
      operationId: personalChat
      parameters:
        - name: X-Eigi-Session-Id
          in: header
          required: false
          description: Stable conversation ID. X-Eigi-Session-Key is accepted as an alias.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AgentChatInput'
            example:
              model: eigi-agent
              messages:
                - role: user
                  content: Hello!
      responses:
        '200':
          description: Successful request
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  object:
                    type: string
                  model:
                    type: string
                  choices:
                    type: array
                    items:
                      type: object
                      properties:
                        index:
                          type: integer
                        message:
                          type: object
                          properties:
                            role:
                              type: string
                            content:
                              type: string
                        finish_reason:
                          type: string
                  usage:
                    type: object
                    additionalProperties: true
            text/event-stream:
              schema:
                type: string
                description: Server-sent events when stream is true.
        '401':
          description: Missing or invalid credentials.
      security:
        - PlatformKeyBearer: []
        - ApiKeyAuth: []
components:
  schemas:
    AgentChatInput:
      type: object
      required:
        - messages
      properties:
        model:
          type: string
          example: eigi-agent
        messages:
          type: array
          items:
            type: object
            required:
              - role
            properties:
              role:
                type: string
                enum:
                  - user
                  - assistant
                  - system
                  - tool
              content:
                oneOf:
                  - type: string
                  - type: array
                    items:
                      type: object
                      additionalProperties: true
              name:
                type: string
          minItems: 1
        stream:
          type: boolean
          default: false
        stream_options:
          type: object
          properties:
            include_usage:
              type: boolean
              default: false
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: Studio API key for server-side requests.
    OAuthAccessToken:
      type: http
      scheme: bearer
      description: OAuth access token issued to an authorized Eigi integration.
    PlatformKeyBearer:
      type: http
      scheme: bearer
      description: The owning account's Studio API key in the Authorization header.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.