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

# Get usage



## OpenAPI

````yaml /openapi.json get /usage
openapi: 3.1.0
info:
  title: NinjaChat API
  version: 1.0.0
  description: >-
    Clean-break NinjaChat v1. Chat and Responses bill actual token usage; images
    and videos use catalog unit pricing.
servers:
  - url: https://www.ninjachat.ai/api/v1
security: []
paths:
  /usage:
    get:
      summary: Get usage
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageResponse'
        '400':
          description: Invalid or unsupported request parameter.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Insufficient balance or project spend limit reached.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Gateway error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: javascript
          label: TypeScript SDK
          source: >-
            import { NinjaChat } from "@ninjachat/sdk";


            const client = new NinjaChat({ apiKey:
            process.env.NINJACHAT_API_KEY! });

            const usage = await client.usage("7d");


            console.log(usage);
        - lang: python
          label: Python SDK
          source: |-
            import os
            from ninjachat import NinjaChat

            client = NinjaChat(api_key=os.environ["NINJACHAT_API_KEY"])
            usage = client.usage("7d")

            print(usage)
components:
  schemas:
    UsageResponse:
      type: object
      properties:
        period:
          type: string
          enum:
            - 1d
            - 7d
            - 30d
        total_requests:
          type: integer
          minimum: 0
        total_cost_cents:
          type: number
          minimum: 0
        total_cost:
          type: string
        daily:
          type: array
          items:
            type: object
            properties:
              date:
                type: string
              requests:
                type: integer
                minimum: 0
              cost_cents:
                type: number
                minimum: 0
            required:
              - date
              - requests
              - cost_cents
            additionalProperties: false
        by_model:
          type: array
          items:
            type: object
            properties:
              model:
                type: string
              requests:
                type: integer
                minimum: 0
              cost_cents:
                type: number
                minimum: 0
              avg_latency_ms:
                type: number
                minimum: 0
            required:
              - model
              - requests
              - cost_cents
              - avg_latency_ms
            additionalProperties: false
        by_endpoint:
          type: array
          items:
            type: object
            properties:
              endpoint:
                type:
                  - string
                  - 'null'
              requests:
                type: integer
                minimum: 0
            required:
              - endpoint
              - requests
            additionalProperties: false
        request_id:
          type: string
      required:
        - period
        - total_requests
        - total_cost_cents
        - total_cost
        - daily
        - by_model
        - by_endpoint
        - request_id
      additionalProperties: false
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            code:
              type: string
            param:
              type:
                - string
                - 'null'
          required:
            - message
            - type
            - code
          additionalProperties: false
      required:
        - error
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: NinjaChat API key
      description: Use an API key created in the NinjaChat developer console.

````