openapi: 3.1.0
info:
  title: PixIA API
  version: 1.0.0
  description: API de IA brasileira em nuvem, compatível com OpenAI v1.
servers:
  - url: https://api.pixia.cloud
security:
  - BearerAuth: []
paths:
  /v1/models:
    get:
      summary: Listar modelos disponíveis
      responses:
        "200":
          description: Lista de modelos
  /v1/chat/completions:
    post:
      summary: Chat completion (sync ou stream)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                model:
                  type: string
                messages:
                  type: array
                  items:
                    type: object
                stream:
                  type: boolean
              required: [model, messages]
      responses:
        "200":
          description: Sucesso
        "401":
          description: API key ausente/inválida
        "402":
          description: Créditos insuficientes
        "500":
          description: Erro interno
        "504":
          description: Timeout
  /v1/embeddings:
    post:
      summary: Gerar embeddings
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                model:
                  type: string
                input:
                  oneOf:
                    - type: string
                    - type: array
                      items:
                        type: string
              required: [input]
      responses:
        "200":
          description: Sucesso
        "400":
          description: input inválido
  /v1/usage:
    get:
      summary: Obter extrato de uso da API key autenticada
      parameters:
        - in: query
          name: limit
          schema:
            type: integer
            default: 100
        - in: query
          name: skip
          schema:
            type: integer
            default: 0
        - in: query
          name: since
          schema:
            type: integer
            description: Timestamp em milissegundos
      responses:
        "200":
          description: Extrato de uso
        "400":
          description: Parâmetros inválidos
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
