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

# Get an organization's usage by model

> Returns one row per model with token counts, cost and request count, summed over a rolling window ending now (`day` is the last 24 hours, `week` the last 7 days, `month` the last 30 days) or over a custom `start` to `end` range of at most 366 days. Costs are integers in nano-USD (10^-9 USD).



## OpenAPI

````yaml /api-reference/cloud-platform-openapi.json get /v1/organizations/{org_id}/usage/by-model
openapi: 3.1.0
info:
  description: Account, organization, workspace and billing routes of NEAR AI Cloud.
  title: NEAR AI Cloud Platform API
  version: '5'
servers:
  - url: https://cloud-platform.near.ai
    description: NEAR AI Cloud Platform
security: []
paths:
  /v1/organizations/{org_id}/usage/by-model:
    get:
      tags:
        - Usage
      summary: Get an organization's usage by model
      description: >-
        Returns one row per model with token counts, cost and request count,
        summed over a rolling window ending now (`day` is the last 24 hours,
        `week` the last 7 days, `month` the last 30 days) or over a custom
        `start` to `end` range of at most 366 days. Costs are integers in
        nano-USD (10^-9 USD).
      operationId: get_organization_usage_by_model
      parameters:
        - description: The organization id (a UUID).
          in: path
          name: org_id
          required: true
          schema:
            type: string
        - description: >-
            `day` (last 24 hours), `week` (last 7 days), `month` (last 30 days),
            or `custom` for the

            `start`/`end` range. Defaults to `month`.
          in: query
          name: period
          required: false
          schema:
            $ref: '#/components/schemas/UsageByModelPeriod'
        - description: >-
            Custom range start (ISO 8601). Setting `start` or `end` selects the
            custom range

            whatever `period` says.
          in: query
          name: start
          required: false
          schema:
            type: string
        - description: >-
            Custom range end, exclusive (ISO 8601). Defaults to now. The range
            may not exceed 366 days.
          in: query
          name: end
          required: false
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageByModelResponse'
          description: Usage per model.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: A parameter is invalid.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Missing or invalid credential.
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: The user is not a member of this organization.
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: The organization does not exist.
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal error.
        '504':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: The query took too long; narrow the time range.
      security:
        - session: []
components:
  schemas:
    UsageByModelPeriod:
      description: Period selector for the by-model usage breakdown.
      enum:
        - day
        - week
        - month
        - custom
      type: string
    UsageByModelResponse:
      description: Per-model usage breakdown response
      properties:
        data:
          items:
            $ref: '#/components/schemas/UsageByModelEntryResponse'
          type: array
        end_date:
          description: >-
            Exclusive end of a custom range. Absent for rolling windows, which
            end now.
          format: date-time
          type:
            - string
            - 'null'
        period:
          description: >-
            `day`, `week` or `month` for a rolling window; `custom` for a
            `start`/`end` range.
          type: string
        start_date:
          format: date-time
          type: string
      required:
        - period
        - start_date
        - data
      type: object
    ErrorResponse:
      description: The body of every error answer on the user routes.
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
      required:
        - error
      type: object
    UsageByModelEntryResponse:
      description: Per-model usage aggregation entry
      properties:
        input_tokens:
          format: int64
          type: integer
        model:
          type: string
        output_tokens:
          format: int64
          type: integer
        request_count:
          format: int64
          type: integer
        total_cost:
          format: int64
          type: integer
        total_cost_display:
          type: string
        total_tokens:
          format: int64
          type: integer
      required:
        - model
        - input_tokens
        - output_tokens
        - total_tokens
        - total_cost
        - total_cost_display
        - request_count
      type: object
    ErrorDetail:
      properties:
        code:
          type:
            - string
            - 'null'
        message:
          type: string
        param:
          type:
            - string
            - 'null'
        type:
          type: string
      required:
        - message
        - type
      type: object
  securitySchemes:
    session:
      bearerFormat: Session token
      description: 'Session token from signing in, sent as `Authorization: Bearer <token>`.'
      scheme: bearer
      type: http

````

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