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

# Per-Request Usage Logs

> Get granular per-request usage logs with filtering. Supports CSV export via format=csv.



## OpenAPI

````yaml /openapi.json get /api/api-keys/logs
openapi: 3.1.0
info:
  title: NinjaChat API
  version: 1.0.0
  description: >-
    Access 40+ AI models through a unified API — chat, image generation, video
    generation, and web search. One API key, one endpoint per type, just change
    the `model` parameter.
servers:
  - url: https://www.ninjachat.ai
security:
  - bearerAuth: []
paths:
  /api/api-keys/logs:
    get:
      tags:
        - Management
      summary: Per-Request Usage Logs
      description: >-
        Get granular per-request usage logs with filtering. Supports CSV export
        via format=csv.
      operationId: listUsageLogs
      parameters:
        - name: limit
          in: query
          schema:
            type: integer
            default: 100
            maximum: 500
          description: Number of records to return.
        - name: offset
          in: query
          schema:
            type: integer
            default: 0
          description: Pagination offset.
        - name: group
          in: query
          schema:
            type: string
            enum:
              - chat
              - search
              - images
              - video
          description: Filter by endpoint type.
        - name: model
          in: query
          schema:
            type: string
          description: Filter by model ID (e.g. gpt-5).
        - name: status
          in: query
          schema:
            type: integer
          description: Filter by HTTP status code (e.g. 200).
        - name: from
          in: query
          schema:
            type: string
            format: date-time
          description: Start date (ISO 8601).
        - name: to
          in: query
          schema:
            type: string
            format: date-time
          description: End date (ISO 8601).
        - name: format
          in: query
          schema:
            type: string
            enum:
              - json
              - csv
            default: json
          description: Response format. Use csv for spreadsheet export.
      responses:
        '200':
          description: Usage logs.
          content:
            application/json:
              schema:
                type: object
                properties:
                  logs:
                    type: array
                    items:
                      type: object
                      properties:
                        timestamp:
                          type: string
                          format: date-time
                        endpoint:
                          type: string
                          example: /api/v1/chat
                        group:
                          type: string
                          example: chat
                        model:
                          type: string
                          example: gpt-5
                        statusCode:
                          type: integer
                          example: 200
                        tokensUsed:
                          type: integer
                          nullable: true
                        latencyMs:
                          type: integer
                          example: 842
                  pagination:
                    type: object
                    properties:
                      total:
                        type: integer
                      limit:
                        type: integer
                      offset:
                        type: integer
                      hasMore:
                        type: boolean
        '401':
          description: Authentication failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ErrorResponse:
      type: object
      description: >-
        OpenAI-compatible error. The top-level `message`, `code`, and
        `request_id` mirror fields inside `error` for convenience.
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              description: Human-readable error description.
            type:
              type: string
              description: >-
                Error category: invalid_request_error, authentication_error,
                rate_limit_error, insufficient_quota, or api_error.
            code:
              type: string
              description: Machine-readable error code.
            param:
              type: string
              nullable: true
              description: The request parameter that caused the error, if any.
        message:
          type: string
          description: Same as error.message.
        code:
          type: string
          description: Same as error.code.
        request_id:
          type: string
          description: Unique request ID, useful when contacting support.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: API key starting with nj_sk_

````