> ## 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.

# FinOps dashboard: per-agent cost/token rows plus fleet-wide summary.



## OpenAPI

````yaml /api-reference/openapi.json get /api/observability/finops/dashboard
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/observability/finops/dashboard:
    get:
      tags:
        - observability
      summary: 'FinOps dashboard: per-agent cost/token rows plus fleet-wide summary.'
      operationId: get_finops_dashboard
      parameters:
        - name: start_time
          in: query
          description: >-
            ISO-8601 window start (default: 30 days ago). Ignored when `range`
            is set.
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: end_time
          in: query
          description: >-
            ISO-8601 window end (default: now). Without it a past-month
            selection

            means "that month through today" rather than that month.
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: range
          in: query
          description: '"24h" | "7d" | "30d" — quick-select range, overrides `start_time`.'
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: agent_id
          in: query
          description: Agent UUID or name — scopes the whole response to one agent.
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: model
          in: query
          description: Exact model id, matched against span model attributes.
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: provider
          in: query
          description: >-
            Provider name filter (e.g. "openai", "anthropic"), matched against

            the `provider` column in `trace_usage` (derived from
            `model_pricing`).
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: org_unit
          in: query
          description: |-
            Org-unit filter — resolved to user_ids by the EE auth layer. OSS
            accepts the param but ignores it (no org hierarchy). EE reads it in
            the handler and passes user_ids to the service.
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: view
          in: query
          description: >-
            "agent" | "workflow" — which attribution source powers the
            response's

            `attributions` field (default "agent").
          required: false
          schema:
            type:
              - string
              - 'null'
        - name: my_agent
          in: query
          description: |-
            When `true`, restricts results to agents owned by the caller.
            Ignored when `agent_id` is also set (already scoped to one agent).
          required: false
          schema:
            type: boolean
      responses:
        '200':
          description: FinOps dashboard data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FinopsDashboardResponse'
        '400':
          description: Malformed filter (range/view/agent_id)
        '401':
          description: Missing or invalid session
components:
  schemas:
    FinopsDashboardResponse:
      type: object
      required:
        - data
        - status_code
        - message
      properties:
        data:
          $ref: '#/components/schemas/FinopsDashboardData'
        message:
          type: string
        status_code:
          type: integer
          format: int32
          minimum: 0
    FinopsDashboardData:
      type: object
      required:
        - summary
        - agents
        - token_usage
        - kpis
        - attributions
        - spend_by_agent
      properties:
        agents:
          type: array
          items:
            $ref: '#/components/schemas/AgentFinopsRow'
        attributions:
          $ref: '#/components/schemas/FinopsAttributions'
        kpis:
          $ref: '#/components/schemas/FinopsKpis'
        spend_by_agent:
          $ref: '#/components/schemas/SpendByAgentBreakdown'
          description: >-
            Pre-computed spend split for the selected window: top-5 agents by
            spend

            plus an "Others" catchall, ready to feed a pie/donut chart without
            any

            client-side aggregation.
        summary:
          $ref: '#/components/schemas/FinopsSummary'
        token_usage:
          $ref: '#/components/schemas/FinopsTokenUsage'
    AgentFinopsRow:
      type: object
      required:
        - agent_id
        - agent_name
        - total_cost
        - operations
        - is_capped
        - avg_cost_per_operation
        - prompt_tokens
        - completion_tokens
        - cache_read_tokens
        - cache_creation_tokens
        - total_tokens
        - tool_call_count
        - container_hours
      properties:
        agent_id:
          type: string
        agent_name:
          type: string
        avg_cost_per_operation:
          type: number
          format: double
        avg_latency_ms:
          type:
            - number
            - 'null'
          format: double
          description: p50 trace-level latency for this agent in the window.
        avg_latency_p95_ms:
          type:
            - number
            - 'null'
          format: double
        avg_latency_p99_ms:
          type:
            - number
            - 'null'
          format: double
        cache_creation_tokens:
          type: integer
          format: int64
          description: Prompt tokens written to provider cache (Anthropic cache creation).
          minimum: 0
        cache_read_tokens:
          type: integer
          format: int64
          description: >-
            Prompt tokens served from provider cache (OpenAI cached / Anthropic
            cache read).
          minimum: 0
        completion_tokens:
          type: integer
          format: int64
          minimum: 0
        container_hours:
          type: number
          format: double
          description: Replica-hours this agent consumed in the dashboard window.
        is_capped:
          type: boolean
          description: |-
            True when `operations` was capped by the token-aggregation trace
            limit — the token/cost fields below undercount the real total.
        operations:
          type: integer
          minimum: 0
        prompt_tokens:
          type: integer
          format: int64
          minimum: 0
        tool_call_count:
          type: integer
          format: int64
          minimum: 0
        total_cost:
          type: number
          format: double
        total_tokens:
          type: integer
          format: int64
          minimum: 0
        version:
          type:
            - string
            - 'null'
    FinopsAttributions:
      oneOf:
        - type: object
          required:
            - rows
            - view
          properties:
            rows:
              type: array
              items:
                $ref: '#/components/schemas/AgentFinopsRow'
            view:
              type: string
              enum:
                - agent
        - type: object
          required:
            - rows
            - view
          properties:
            rows:
              type: array
              items:
                $ref: '#/components/schemas/WorkflowFinopsRow'
            view:
              type: string
              enum:
                - workflow
    FinopsKpis:
      type: object
      required:
        - total_spend
        - total_tokens
        - cost_per_operation
        - avg_latency_ms
        - total_agents
        - active_agents
        - total_operations
        - total_tool_calls
        - latency_p95_ms
        - latency_p99_ms
      properties:
        active_agents:
          $ref: '#/components/schemas/KpiValue'
        avg_latency_ms:
          $ref: '#/components/schemas/KpiValue'
          description: Fleet-wide p50 latency (label kept for UI backward compat).
        cost_per_operation:
          $ref: '#/components/schemas/KpiValue'
        latency_p95_ms:
          $ref: '#/components/schemas/KpiValue'
        latency_p99_ms:
          $ref: '#/components/schemas/KpiValue'
        total_agents:
          $ref: '#/components/schemas/KpiValue'
        total_operations:
          $ref: '#/components/schemas/KpiValue'
        total_spend:
          $ref: '#/components/schemas/KpiValue'
        total_tokens:
          $ref: '#/components/schemas/KpiValue'
        total_tool_calls:
          $ref: '#/components/schemas/KpiValue'
    SpendByAgentBreakdown:
      type: object
      required:
        - slices
        - total_spend_usd
      properties:
        slices:
          type: array
          items:
            $ref: '#/components/schemas/SpendPieSlice'
          description: |-
            Top-5 agents by spend, followed by an "Others" entry when there are
            more than 5 agents. Empty when there is no spend in the window.
        total_spend_usd:
          type: number
          format: double
    FinopsSummary:
      type: object
      required:
        - total_cost
        - total_operations
        - operations_last_24h
        - average_cost
        - active_agents
        - total_agents
        - total_container_hours
        - unpriced_calls
        - estimated_cost
        - unknown_confidence_calls
      properties:
        active_agents:
          type: integer
          minimum: 0
        average_cost:
          type: number
          format: double
        estimated_cost:
          type: number
          format: double
          description: >-
            Sum of rows explicitly priced using inferred rates or usage
            evidence.
        operations_last_24h:
          type: integer
          minimum: 0
        total_agents:
          type: integer
          minimum: 0
        total_container_hours:
          type: number
          format: double
          description: >-
            Replica-hours consumed in the dashboard window — includes agents
            that

            have since been deleted (their sessions survive deletion).
        total_cost:
          type: number
          format: double
        total_operations:
          type: integer
          minimum: 0
        unknown_confidence_calls:
          type: integer
          description: Older materializations without recorded pricing confidence.
          minimum: 0
        unpriced_calls:
          type: integer
          description: >-
            Calls in the window that consumed tokens but carry no cost (no price
            row

            for the model — e.g. a custom provider with no price book).
            `SUM(cost_usd)`

            silently skips these, so `total_cost` under-reports; this surfaces
            the gap

            as a known number rather than a smaller one.
          minimum: 0
    FinopsTokenUsage:
      type: object
      required:
        - total_tokens
        - prompt_tokens
        - completion_tokens
        - cache_read_tokens
        - cache_creation_tokens
        - avg_tokens_per_operation
      properties:
        avg_tokens_per_operation:
          type: integer
          format: int64
          minimum: 0
        cache_creation_tokens:
          type: integer
          format: int64
          description: Prompt tokens written to provider cache (Anthropic cache creation).
          minimum: 0
        cache_read_tokens:
          type: integer
          format: int64
          description: >-
            Prompt tokens served from provider cache (OpenAI cached / Anthropic
            cache read).
          minimum: 0
        completion_tokens:
          type: integer
          format: int64
          minimum: 0
        prompt_tokens:
          type: integer
          format: int64
          minimum: 0
        total_tokens:
          type: integer
          format: int64
          minimum: 0
    WorkflowFinopsRow:
      type: object
      required:
        - maf_id
        - workflow_name
        - total_cost
        - executions
        - avg_cost_per_execution
        - prompt_tokens
        - completion_tokens
        - cache_read_tokens
        - cache_creation_tokens
        - total_tokens
      properties:
        avg_cost_per_execution:
          type: number
          format: double
        avg_latency_ms:
          type:
            - number
            - 'null'
          format: double
        cache_creation_tokens:
          type: integer
          format: int64
          description: Prompt tokens written to provider cache (Anthropic cache creation).
          minimum: 0
        cache_read_tokens:
          type: integer
          format: int64
          description: >-
            Prompt tokens served from provider cache (OpenAI cached / Anthropic
            cache read).
          minimum: 0
        completion_tokens:
          type: integer
          format: int64
          minimum: 0
        executions:
          type: integer
          minimum: 0
        maf_id:
          type: string
        prompt_tokens:
          type: integer
          format: int64
          minimum: 0
        total_cost:
          type: number
          format: double
        total_tokens:
          type: integer
          format: int64
          minimum: 0
        workflow_name:
          type: string
    KpiValue:
      type: object
      required:
        - current
        - previous
      properties:
        change_pct:
          type:
            - number
            - 'null'
          format: double
          description: |-
            `(current - previous) / previous * 100`, rounded to 2dp. `None` when
            `previous == 0` — an undefined percentage, not a fabricated 0 or ∞.
        current:
          type: number
          format: double
        previous:
          type: number
          format: double
    SpendPieSlice:
      type: object
      required:
        - agent_name
        - spend_usd
        - pct
      properties:
        agent_name:
          type: string
        pct:
          type: number
          format: double
          description: Percentage of total window spend, rounded to 2dp.
        spend_usd:
          type: number
          format: double

````