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

# Per-agent usage breakdown for the caller, ordered by total tokens.



## OpenAPI

````yaml /api-reference/openapi.json get /api/usage/by-agent
openapi: 3.1.0
info:
  title: Nasiko API
  description: >-
    HTTP API for the Nasiko OpenRuntime: agents, coding harnesses, TokenOps,
    routing, MCP, and secrets. Spec is generated from annotated routes; some
    surfaces are documented on the hand-written pages alongside this file.
  license:
    name: ''
  version: 0.1.0
servers: []
security: []
tags:
  - name: secrets
    description: Encrypted per-user agent secrets
  - name: catalog
    description: >-
      Agent catalog: registration, discovery, versions, per-agent secrets, and
      source import
  - name: agents
    description: >-
      Agent lifecycle: deployments, LLM routing config, update/rollback,
      upload-and-deploy
  - name: orchestrator
    description: >-
      A2A dispatch: routing-engine/ReAct orchestrator and direct agent chat,
      plus routing stats
  - name: users
    description: >-
      User management: CRUD, roles, credentials, accessible agents
      (superuser-only)
  - name: usage
    description: Per-user token usage and cost reporting
  - name: observability
    description: Sessions, traces, spans, agent logs, and FinOps reporting
  - name: llm-router
    description: LLM routing presets, provider/model catalog, and tier→model registry
  - name: mcp
    description: >-
      MCP gateway: agent-facing JSON-RPC tool calls, connector
      registration/upload/sharing, credentials & OAuth, and per-agent tool
      permissions
paths:
  /api/usage/by-agent:
    get:
      tags:
        - usage
      summary: Per-agent usage breakdown for the caller, ordered by total tokens.
      operationId: by_agent
      parameters:
        - name: limit
          in: query
          description: 'Page size (default: 50).'
          required: false
          schema:
            type: integer
            format: int64
        - name: offset
          in: query
          description: 'Page offset (default: 0).'
          required: false
          schema:
            type: integer
            format: int64
        - name: q
          in: query
          description: >-
            Case-insensitive substring filter: on the agent name for `by-agent`,

            on the model name for `by-model`. Omitted or empty matches
            everything.
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: days
          in: query
          description: 'Look-back window in days (default: 30).'
          required: false
          schema:
            type: integer
            format: int64
      responses:
        '200':
          description: Paginated per-agent usage rows
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentUsagePage'
        '401':
          description: Missing or invalid session
components:
  schemas:
    AgentUsagePage:
      type: object
      description: |-
        Doc-only schema for `crate::Paginated<AgentUsage>` (the generic envelope
        itself is not utoipa-annotated).
      required:
        - data
        - total
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/AgentUsage'
        total:
          type: integer
          minimum: 0
    AgentUsage:
      type: object
      required:
        - request_count
        - total_input_tokens
        - total_output_tokens
        - total_tokens
        - total_cost_usd
      properties:
        agent_id:
          type:
            - string
            - 'null'
          format: uuid
        agent_name:
          type:
            - string
            - 'null'
        avg_latency_ms:
          type:
            - number
            - 'null'
          format: double
        request_count:
          type: integer
          format: int64
        total_cost_usd:
          type: number
          format: double
        total_input_tokens:
          type: integer
          format: int64
        total_output_tokens:
          type: integer
          format: int64
        total_tokens:
          type: integer
          format: int64

````