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

# Gemini Completions

<Note>
  The request and response fields follow the official Responses API format.
  For details, refer to the <a href="https://ai.google.dev/gemini-api/docs/text-generation" target="_blank">Google official documentation</a>.
</Note>


## OpenAPI

````yaml openapi/en/llm.json POST /gemini/chat/completions
openapi: 3.1.0
info:
  title: LLM API DOCS
  version: 1.0.0
  description: TTAPI LLM API service.
servers:
  - url: https://api.ttapi.io
security: []
paths:
  /gemini/chat/completions:
    post:
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GeminiRequest'
      responses:
        '200':
          description: >-
            Successful response (stream=false returns JSON, stream=true returns
            Gemini stream)
          content:
            application/json:
              schema:
                type: object
                properties:
                  choices:
                    type: array
                    description: List of response results
                    items:
                      type: object
                      properties:
                        finish_reason:
                          type: string
                          description: Response stop reason
                          example: stop
                        index:
                          type: integer
                          description: Result index
                          example: 0
                        message:
                          type: object
                          description: Response message body
                          properties:
                            content:
                              type: string
                              description: Content generated by Gemini
                              example: >-
                                Hello! Nice to chat with you.


                                How can I help you? Or what would you like to
                                talk about? 😊
                            role:
                              type: string
                              description: Message role
                              example: assistant
                          required:
                            - content
                            - role
                      required:
                        - finish_reason
                        - index
                        - message
                  created:
                    type: integer
                    description: Response creation timestamp (seconds)
                    example: 1757472417
                  id:
                    type: string
                    description: Unique request identifier
                    example: oebAaMTvMfCUjMcP_prYwAs
                  model:
                    type: string
                    description: Gemini model version used
                    example: gemini-2.5-pro
                  object:
                    type: string
                    description: Response object type
                    example: chat.completion
                  usage:
                    type: object
                    description: Token usage statistics
                    properties:
                      completion_tokens:
                        type: integer
                        description: Token count consumed by generated content
                        example: 21
                      prompt_tokens:
                        type: integer
                        description: Token count consumed by prompt
                        example: 3
                      total_tokens:
                        type: integer
                        description: Total token count consumed
                        example: 1466
                    required:
                      - completion_tokens
                      - prompt_tokens
                      - total_tokens
        '400':
          $ref: '#/components/responses/400Response'
        '401':
          $ref: '#/components/responses/401Response'
      security:
        - CustomApiKey: []
components:
  schemas:
    GeminiRequest:
      type: object
      properties:
        messages:
          type: array
          items:
            type: object
            properties:
              role:
                type: string
              content:
                type: string
          example:
            - role: user
              content: Hello!
        model:
          type: string
          description: >-
            Models supported by TTAPI, see [Gemini Supported
            Models](/grids/cn/start/pricing/llm)
        stream:
          type: boolean
          default: 'false'
          description: >-
            Whether to use server-sent events for progressive response
            transmission
      required:
        - messages
        - model
  responses:
    400Response:
      description: Parameter error
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: FAILED
              message:
                type: string
                example: '"prompt" cannot be empty.'
              data:
                type: object
            required:
              - status
              - message
    401Response:
      description: Authorization failed
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: FAILED
              message:
                type: string
                example: Wrong TT-API-KEY or email is not activated.
            required:
              - status
              - message
  securitySchemes:
    CustomApiKey:
      type: apiKey
      in: header
      name: TT-API-KEY
      description: >-
        You can obtain your API key from the <a
        href='https://dashboard.ttapi.io' target='_blank'>TTAPI Dashboard</a>.

````