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

# Get LLM consumption per user

> Returns the LLM requests, tokens, cost, and carbon footprint of each
user of the organization over the period. `totals` always covers the
whole organization, whatever the page or search.

- **Pagination** applies when `page` or `page_size` is sent.
  Otherwise, every user is returned in one response (up to 10,000;
  `meta.truncated` is `true` beyond).
- **`format=csv`** returns the full list as a `;`-separated CSV file,
  ignoring pagination.

The first page sorted by cost, without search, may be served from a
snapshot up to 20 minutes old (`meta.cached`).

Requires `ai-insights-v2:analytics` (`read`). Rate limit: 50
requests per minute.




## OpenAPI

````yaml /api-reference/ai-insights-v2/swagger.yml get /v1/analytics/users/consumption
openapi: 3.0.3
info:
  version: 1.0.0
  title: AI Insights API
  description: |
    Public REST API for the Prisme.ai AI Insights workspace - analyzed
    conversations, analysis triggering and status, evaluation criteria,
    message feedback, organization analytics, LLM consumption, memory
    analytics, and the agent relationship graph.

    **Organization scope.** Every endpoint reads and writes the data of the
    caller's organization, taken from the session (or from the org API key).
    No parameter lets a caller target another organization.

    **Permissions.** Each endpoint checks an organization IAM permission
    `ai-insights-v2:<resource>` with the action `read` or `write`
    (`manage` grants both). The resources are `conversations`, `feedback`,
    `analytics`, and `queue`; each operation states the one it requires.
    Platform admins and workspace admins are always allowed.

    **Rate limits.** Limits are counted per caller (user, or org API key)
    and per endpoint, over a sliding window. Depending on the endpoint, an
    exceeded limit returns one of two 429 bodies; both are documented on
    each operation.
  contact:
    name: Prisme.ai
    url: https://prisme.ai
servers:
  - url: https://{host}/v2/workspaces/slug:ai-insights-v2/webhooks
    description: Prisme.ai workspace webhooks
    variables:
      host:
        default: api.studio.prisme.ai
        description: API host (override for self-hosted or sandbox)
security:
  - BearerAuth: []
  - OrgApiKeyAuth: []
tags:
  - name: Insights
    description: Per-conversation analysis results and analysis status.
  - name: Agents
    description: >-
      Analysis triggering, evaluation criteria, conversations, and users of one
      agent.
  - name: Feedback
    description: Like / dislike feedback on agent messages.
  - name: Analytics
    description: Organization-wide usage, quality, latency, and adoption metrics.
  - name: Consumption
    description: LLM requests, tokens, cost, and carbon footprint, per user and over time.
  - name: Queue
    description: State of the conversation analysis queue.
  - name: Memories
    description: Analytics built from the memories users accumulate with agents.
  - name: Graph
    description: >-
      Agent relationship graph - tools, categories, delegations, similarity, and
      clusters.
paths:
  /v1/analytics/users/consumption:
    get:
      tags:
        - Consumption
      summary: Get LLM consumption per user
      description: |
        Returns the LLM requests, tokens, cost, and carbon footprint of each
        user of the organization over the period. `totals` always covers the
        whole organization, whatever the page or search.

        - **Pagination** applies when `page` or `page_size` is sent.
          Otherwise, every user is returned in one response (up to 10,000;
          `meta.truncated` is `true` beyond).
        - **`format=csv`** returns the full list as a `;`-separated CSV file,
          ignoring pagination.

        The first page sorted by cost, without search, may be served from a
        snapshot up to 20 minutes old (`meta.cached`).

        Requires `ai-insights-v2:analytics` (`read`). Rate limit: 50
        requests per minute.
      operationId: getUsersConsumption
      parameters:
        - $ref: '#/components/parameters/Period'
        - $ref: '#/components/parameters/FromDate'
        - $ref: '#/components/parameters/ToDate'
        - in: query
          name: page
          schema:
            type: integer
            minimum: 1
            default: 1
          description: Page number (1-based).
        - in: query
          name: page_size
          schema:
            type: integer
            minimum: 1
            maximum: 200
            default: 50
          description: Users per page.
        - in: query
          name: sort_by
          schema:
            type: string
            enum:
              - cost
              - tokens
              - completions
              - embeddings
              - messages
              - carbon
            default: cost
          description: Sort field. Any other value sorts by `cost`.
        - in: query
          name: sort_dir
          schema:
            type: string
            enum:
              - asc
              - desc
            default: desc
          description: Sort direction.
        - in: query
          name: q
          schema:
            type: string
            maxLength: 128
          description: >-
            Only return users whose name or email matches. Does not change
            `totals`.
        - in: query
          name: format
          schema:
            type: string
            enum:
              - json
              - csv
            default: json
          description: Response format.
      responses:
        '200':
          description: Consumption per user.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsersConsumption'
            text/csv:
              schema:
                type: string
                description: >
                  Header row:

                  `user_id;email;name;requests_completions;requests_embeddings;tokens_input;tokens_output;cost;carbon_kgco2;messages;conversations`.

                  Sent as an attachment named
                  `users-consumption-<org>-<period>.csv`.
        '400':
          $ref: '#/components/responses/InvalidArguments'
        '401':
          $ref: '#/components/responses/Unauthenticated'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
        '503':
          description: The member search (`q`) or the usage search failed. Retry later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: AnalyticsSourceUnavailable
                message: The LLM usage search failed, try again later
components:
  parameters:
    Period:
      in: query
      name: period
      schema:
        type: string
        enum:
          - 7d
          - 30d
          - 90d
        default: 30d
      description: >-
        Sliding window ending now. Any other value uses `30d`. Ignored when both
        `from_date` and `to_date` are set.
    FromDate:
      in: query
      name: from_date
      schema:
        type: string
        format: date-time
        maxLength: 64
      description: >-
        Start of a custom range, ISO 8601. Used only together with `to_date`,
        and then takes precedence over `period` (`period` is returned as
        `custom`).
    ToDate:
      in: query
      name: to_date
      schema:
        type: string
        format: date-time
        maxLength: 64
      description: End of a custom range, ISO 8601. Used only together with `from_date`.
  schemas:
    UsersConsumption:
      type: object
      properties:
        users:
          type: array
          items:
            allOf:
              - $ref: '#/components/schemas/Contact'
              - type: object
                properties:
                  completions:
                    type: integer
                  embeddings:
                    type: integer
                  tokens_input:
                    type: integer
                    description: Completion input and embedding tokens.
                  tokens_output:
                    type: integer
                  tokens:
                    type: integer
                  cost:
                    type: number
                  carbon_kgco2:
                    type: number
                  carbon:
                    type: number
                    description: Same as `carbon_kgco2`.
                  messages:
                    type: integer
                  conversations:
                    type: integer
        totals:
          type: object
          description: Whole organization over the period.
          properties:
            cost:
              type: number
            tokens:
              type: integer
            carbon_kgco2:
              type: number
        meta:
          allOf:
            - $ref: '#/components/schemas/CachedPeriodMeta'
            - type: object
              properties:
                total:
                  type: integer
                  description: >-
                    Number of users with usage (approximate on very large
                    organizations).
                page:
                  type: integer
                page_size:
                  type: integer
                sort_by:
                  type: string
                sort_dir:
                  type: string
                q:
                  type: string
                truncated:
                  type: boolean
                  description: '`true` when more users exist than could be returned.'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: >-
            Error code (e.g. `FORBIDDEN`), or error message on some validation
            errors.
        message:
          type: string
          description: Human-readable message.
    Contact:
      type: object
      properties:
        user_id:
          type: string
        name:
          type: string
          description: First and last name. Absent when the user cannot be resolved.
        email:
          type: string
          description: Absent when the user cannot be resolved.
    CachedPeriodMeta:
      allOf:
        - $ref: '#/components/schemas/PeriodMeta'
        - type: object
          properties:
            cached:
              type: boolean
              description: '`true` when served from a snapshot.'
            cached_at:
              type: string
              format: date-time
              description: When the snapshot was computed. Only when `cached` is `true`.
    RuntimeError:
      type: object
      description: Error raised by the Prisme.ai runtime before the endpoint logic runs.
      required:
        - error
        - message
      properties:
        error:
          type: string
        message:
          type: string
        details:
          type: object
          additionalProperties: true
    PeriodMeta:
      type: object
      properties:
        period:
          type: string
          description: >-
            The `period` sent (or `30d`), or `custom` for a `from_date` /
            `to_date` range.
        period_start:
          type: string
          format: date-time
        period_end:
          type: string
          format: date-time
        generated_at:
          type: string
          format: date-time
        cache_ttl:
          type: integer
          description: Suggested client cache duration, in seconds.
  responses:
    InvalidArguments:
      description: >-
        A parameter does not match its schema (length, pattern, type, or
        required field).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RuntimeError'
          example:
            error: InvalidArgumentsError
            message: Invalid arguments
            details:
              errors: []
    Unauthenticated:
      description: Missing or invalid credentials, or no organization context.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: UNAUTHORIZED
            message: Authentication required
    Forbidden:
      description: The caller lacks the permission required by the endpoint.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: FORBIDDEN
            message: 'Access denied: missing permission ''ai-insights-v2:analytics:read'''
    RateLimited:
      description: Rate limit exceeded. Retry later.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: RATE_LIMITED
            message: Rate limit exceeded
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        User-bound credential carrying an identity: either a session JWT
        or a user access token (`at:*`) generated from the user settings UI.
        Send as `Authorization: Bearer <token>`. The organization and the
        permissions applied are those of this user.
    OrgApiKeyAuth:
      type: apiKey
      in: header
      name: x-prismeai-api-key
      description: |
        Organization API key (`iak_{orgSlug}_{uuid}`), managed from the
        AI Governance UI. It is not tied to a user: its access is defined by
        the permissions attached to it, and all keys of an organization share
        the same rate-limit counters. Endpoints that describe "your own"
        data, such as `GET /v1/users/{user_id}`, need a user credential.
        Send as `x-prismeai-api-key: iak_...`.

````

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