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

# Obter análises do espaço de trabalho

> Obter agregados filtrados de custos, solicitações e tokens do espaço de trabalho.

<Note>Este endpoint requer uma chave de API de gerenciamento com `analytics:read`.</Note>

Filtre por data, rótulo da solicitação, chave de API, usuário final, modelo, provedor, endpoint, origem da credencial ou resultado. Os resultados são agrupados por data, modelo, provedor e endpoint, com paginação estável.

Os intervalos são limitados aos últimos 30 dias UTC completos e a no máximo 10.000 solicitações de origem.


## OpenAPI

````yaml pt-BR/openapi/v1/openapi.localized.yaml GET /analytics
openapi: 3.0.3
info:
  title: Phaseo Gateway API
  description: >-
    Uma API de gateway para acessar diversos modelos de IA por meio de endpoints
    compatíveis com OpenAI.
  version: 1.0.0
  contact:
    name: Phaseo
    url: https://phaseo.app
    email: danielbutler500@gmail.com
servers:
  - url: https://api.phaseo.app/v1
    description: Roteamento global
security:
  - BearerAuth: []
tags:
  - name: Gateway
    description: Core Phaseo Gateway operations.
paths:
  /analytics:
    get:
      tags:
        - Gateway
      summary: Obter análises do espaço de trabalho
      description: >-
        Retorna agregados de custo, solicitações e tokens agrupados por data,
        modelo, provedor e endpoint para os últimos 30 dias UTC completos.
      operationId: getActivityAlias
      parameters:
        - name: date
          in: query
          description: >-
            Filtra por uma única data UTC nos últimos 30 dias completos
            (YYYY-MM-DD).
          schema:
            type: string
            format: date
        - name: label_key
          in: query
          description: >-
            Chave de rótulo de solicitação a incluir no recorte de gastos. Deve
            ser fornecida junto com label_value.
          schema:
            type: string
            maxLength: 64
            pattern: ^[A-Za-z0-9_.:-]{1,64}$
        - name: label_value
          in: query
          description: >-
            Valor de rótulo de solicitação a incluir no recorte de gastos. Deve
            ser fornecido junto com label_key.
          schema:
            type: string
            maxLength: 256
        - name: key_id
          in: query
          description: Filtra por identificador de chave de API.
          schema:
            type: string
        - name: end_user_id
          in: query
          description: Filtra por identificador de usuário final definido pelo aplicativo.
          schema:
            type: string
            maxLength: 256
        - name: model
          in: query
          description: Filtra pelo slug canônico do modelo solicitado ou roteado.
          schema:
            $ref: '#/components/schemas/ModelId'
        - name: provider
          in: query
          description: Filtra pelo slug do provedor.
          schema:
            type: string
            maxLength: 128
        - name: endpoint
          in: query
          description: Filtra por identificador do endpoint do gateway.
          schema:
            type: string
            maxLength: 128
        - name: byok
          in: query
          description: Filtra tráfego gerenciado ou BYOK.
          schema:
            type: boolean
        - name: success
          in: query
          description: Filtra solicitações bem-sucedidas ou com falha.
          schema:
            type: boolean
        - $ref: '#/components/parameters/Offset'
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 1000
            default: 1000
      responses:
        '200':
          description: Obtido
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalyticsResponse'
        '400':
          description: Erro de solicitação inválida
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Não autorizado
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Erro de acesso proibido
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Erro interno do servidor
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ModelId:
      type: string
      description: >-
        Identificador do modelo. É uma string de execução, então novos modelos
        podem ser usados sem esperar por uma atualização do SDK.
      example: ai21/jamba-1.5-large
    AnalyticsResponse:
      type: object
      required:
        - data
        - total_count
        - offset
        - limit
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/ActivityEntry'
        total_count:
          type: integer
          minimum: 0
        offset:
          type: integer
          minimum: 0
        limit:
          type: integer
          minimum: 1
          maximum: 1000
      additionalProperties: false
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        ok:
          type: boolean
          example: false
        error:
          oneOf:
            - type: string
            - type: object
              additionalProperties: true
          example: error_type
        message:
          type: string
          example: Human-readable error message
        description:
          type: string
          example: Additional error details.
        generation_id:
          type: string
          example: G-abc123
        status_code:
          type: integer
          example: 502
        error_type:
          type: string
          enum:
            - user
            - system
          example: system
        error_origin:
          type: string
          enum:
            - user
            - gateway
            - upstream
          example: upstream
        reason:
          type: string
          example: all_candidates_failed
        attempt_count:
          type: integer
          example: 2
        failed_providers:
          type: array
          items:
            type: string
          example:
            - google-ai-studio
            - openai
        failed_statuses:
          type: array
          items:
            type: integer
          example:
            - 403
            - 429
        upstream_error:
          $ref: '#/components/schemas/ErrorUpstreamError'
        failure_sample:
          type: array
          items:
            $ref: '#/components/schemas/ErrorFailureSampleItem'
        provider_failure_diagnostics:
          $ref: '#/components/schemas/ErrorProviderFailureDiagnostics'
        routing_diagnostics:
          $ref: '#/components/schemas/ErrorRoutingDiagnostics'
        provider_candidate_diagnostics:
          $ref: '#/components/schemas/ErrorProviderCandidateDiagnostics'
        provider_enablement:
          $ref: '#/components/schemas/ErrorProviderEnablementDiagnostics'
        missing_pricing_providers:
          type: array
          items:
            type: string
        provider_payment_required_provider:
          type: string
          example: openai
        provider_payment_required_support_notice:
          type: string
          example: >-
            Our upstream provider billing appears to be unavailable. If this
            persists, contact support.
        details:
          type: array
          items:
            type: object
            additionalProperties: true
      additionalProperties: true
    ActivityEntry:
      type: object
      required:
        - date
        - model
        - model_permaslug
        - endpoint_id
        - provider_name
        - usage
        - byok_usage_inference
        - requests
        - prompt_tokens
        - completion_tokens
        - reasoning_tokens
      properties:
        date:
          type: string
          format: date
          example: '2025-08-24T00:00:00.000Z'
        model:
          type: string
          example: openai/gpt-4.1
        model_permaslug:
          type: string
          example: openai/gpt-4.1-2025-04-14
        endpoint_id:
          type: string
          example: chat.completions
        provider_name:
          type: string
          example: OpenAI
        usage:
          type: number
          example: 0.015
        byok_usage_inference:
          type: number
          example: 0.012
        requests:
          type: integer
          example: 5
        prompt_tokens:
          type: integer
          example: 50
        completion_tokens:
          type: integer
          example: 125
        reasoning_tokens:
          type: integer
          example: 25
      additionalProperties: false
    ErrorUpstreamError:
      type: object
      properties:
        code:
          type: string
          nullable: true
          example: PERMISSION_DENIED
        message:
          type: string
          nullable: true
          example: The caller does not have permission.
        description:
          type: string
          nullable: true
        param:
          type: string
          nullable: true
    ErrorFailureSampleItem:
      type: object
      properties:
        provider:
          type: string
          nullable: true
        type:
          type: string
          nullable: true
        status:
          type: integer
          nullable: true
        upstream_error_code:
          type: string
          nullable: true
        upstream_error_message:
          type: string
          nullable: true
        upstream_error_description:
          type: string
          nullable: true
        upstream_error_param:
          type: string
          nullable: true
        upstream_payload_preview:
          type: string
          nullable: true
        retryable:
          type: boolean
          nullable: true
      additionalProperties: true
    ErrorProviderFailureDiagnostics:
      type: object
      properties:
        category:
          type: string
          enum:
            - credentials_not_configured
            - credentials_invalid_or_forbidden
            - provider_access_missing
            - region_or_project_restriction
            - model_unavailable_for_endpoint
            - rate_limited
            - server_error
        hint:
          type: string
        provider:
          type: string
          nullable: true
    ErrorRoutingDiagnostics:
      type: object
      properties:
        filterStages:
          type: array
          items:
            type: object
            properties:
              stage:
                type: string
              beforeCount:
                type: integer
              afterCount:
                type: integer
              droppedProviders:
                type: array
                items:
                  type: object
                  properties:
                    providerId:
                      type: string
                      nullable: true
                    reason:
                      type: string
                      nullable: true
                  additionalProperties: true
            additionalProperties: true
      additionalProperties: true
    ErrorProviderCandidateDiagnostics:
      type: object
      properties:
        totalProviders:
          type: integer
        supportsEndpointCount:
          type: integer
        candidateCount:
          type: integer
        droppedUnsupportedEndpoint:
          type: array
          items:
            type: string
        droppedMissingAdapter:
          type: array
          items:
            type: object
            properties:
              providerId:
                type: string
                nullable: true
              endpoint:
                type: string
                nullable: true
            additionalProperties: true
      additionalProperties: true
    ErrorProviderEnablementDiagnostics:
      type: object
      properties:
        capability:
          type: string
        providersBefore:
          type: array
          items:
            type: string
        providersAfter:
          type: array
          items:
            type: string
        dropped:
          type: array
          items:
            type: object
            properties:
              providerId:
                type: string
                nullable: true
              reason:
                type: string
                nullable: true
            additionalProperties: true
      additionalProperties: true
  parameters:
    Offset:
      name: offset
      in: query
      required: false
      description: Número de registros a ignorar.
      schema:
        type: integer
        minimum: 0
        default: 0
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Autenticação com token Bearer

````

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