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

# Get API Key Usage

> Get usage statistics for a specific API key within a date range

Get usage statistics for a specific API key within a date range. Supports aggregation by different time periods and optional grouping by user, model, or custom fields.


## OpenAPI

````yaml GET /v1/manage/apikey/{id}/usage
openapi: 3.0.3
info:
  title: Requesty API
  description: Requesty API for AI model routing and key management
  version: 1.0.0
servers:
  - url: https://api-v2.requesty.ai
    description: Management API endpoint
  - url: https://router.requesty.ai
    description: Inference router endpoint
security:
  - BearerAuth: []
paths:
  /v1/manage/apikey/{id}/usage:
    servers:
      - url: https://api-v2.requesty.ai
        description: Management API endpoint
    get:
      summary: Get API key usage
      description: Get usage statistics for a specific API key within a date range
      operationId: getApiKeyUsage
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GetApiKeyUsageRequest'
      responses:
        '200':
          description: Successfully retrieved usage data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetApiKeyUsageResponse'
        '400':
          description: Bad request - malformed payload or invalid parameters.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - missing or empty Authorization header.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Payment required - organization balance exhausted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden - invalid token or model not in access list.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not found - provider/model not supported.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded. Retry after the Retry-After header value.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: Bad gateway - upstream provider returned an invalid response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    GetApiKeyUsageRequest:
      type: object
      properties:
        start:
          type: string
          format: date-time
          description: >-
            Start date in RFC3339 format (e.g., 2025-01-01T00:00:00Z). Required.
            The date range cannot exceed 100 days from start to end.
          example: '2025-01-01T00:00:00Z'
        end:
          type: string
          format: date-time
          description: >-
            End date in RFC3339 format (e.g., 2025-01-31T23:59:59Z). Optional.
            Defaults to 24 hours from start if not specified. Must be after
            start date. The date range cannot exceed 100 days.
          example: '2025-01-31T23:59:59Z'
        group_by:
          type: array
          items:
            type: string
          description: 'Fields to group by: user_id, model_requested, or extra.<field_name>'
        resolution:
          type: string
          enum:
            - hour
            - day
            - month
          default: day
          description: Time resolution for aggregation
      required:
        - start
    GetApiKeyUsageResponse:
      type: object
      properties:
        usage:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/ApiKeyUsageEntry'
          description: Map of period (string) to usage entry
      required:
        - usage
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - origin
            - message
          properties:
            origin:
              type: string
              enum:
                - router
                - provider
              description: >-
                Whether the error originated from Requesty's router or an
                upstream provider.
            message:
              type: string
              description: Human-readable error description.
    ApiKeyUsageEntry:
      type: object
      properties:
        completions_requests:
          type: integer
        spend:
          type: number
          format: decimal
        input_tokens:
          type: integer
        output_tokens:
          type: integer
        total_tokens:
          type: integer
        grouped_data:
          type: array
          items:
            $ref: '#/components/schemas/ApiKeyUsageGrouped'
    ApiKeyUsageGrouped:
      type: object
      properties:
        group_by_values:
          type: object
          additionalProperties: true
        completions_requests:
          type: integer
        spend:
          type: number
          format: decimal
        input_tokens:
          type: integer
        output_tokens:
          type: integer
        total_tokens:
          type: integer
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: API key for authentication

````