{
  "openapi": "3.1.0",
  "info": {
    "title": "IO Intelligence",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.io.solutions"
    }
  ],
  "security": [
    {
      "sec0": []
    }
  ],
  "paths": {
    "/v1/api-keys/sub-keys/usage": {
      "get": {
        "tags": [
          "Sub-API Keys"
        ],
        "summary": "Get All Sub-Keys Usage",
        "description": "Returns token consumption and credit cost for every sub-key owned by the authenticated admin, broken down by model for both today and all time.",
        "operationId": "get_all_keys_usage",
        "parameters": [
          {
            "name": "x-api-key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "description": "Admin API key (io.net Intelligence)",
              "title": "X-Api-Key"
            },
            "description": "Admin API key."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AllKeysUsageResponse"
                },
                "example": {
                  "status": "succeeded",
                  "data": {
                    "keys": [
                      {
                        "api_key_id": "71775d2e-fbcc-4ef4-aa30-8aaeb82062c0",
                        "description": "Partner integration key",
                        "display": "acme-v2-eyJh...c0eQ",
                        "today": {
                          "models": [
                            {
                              "model_name": "meta-llama/Llama-3.3-70B-Instruct",
                              "input_tokens": 1500,
                              "output_tokens": 320,
                              "credit_cost": 2.4e-05
                            }
                          ],
                          "total_input_tokens": 1500,
                          "total_output_tokens": 320,
                          "total_credit_cost": 2.4e-05
                        },
                        "all_time": {
                          "models": [
                            {
                              "model_name": "meta-llama/Llama-3.3-70B-Instruct",
                              "input_tokens": 48000,
                              "output_tokens": 12000,
                              "credit_cost": 0.000834
                            }
                          ],
                          "total_input_tokens": 48000,
                          "total_output_tokens": 12000,
                          "total_credit_cost": 0.000834
                        }
                      }
                    ],
                    "totals": {
                      "today_credit_cost": 2.4e-05,
                      "all_time_credit_cost": 0.000834
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized \u2014 invalid or missing API key"
          },
          "503": {
            "description": "Intelligence database unavailable"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "sec0": {
        "type": "oauth2",
        "flows": {}
      }
    },
    "schemas": {
      "ModelUsageBreakdown": {
        "type": "object",
        "title": "ModelUsageBreakdown",
        "properties": {
          "model_name": {
            "type": "string",
            "title": "Model Name"
          },
          "input_tokens": {
            "type": "integer",
            "title": "Input Tokens"
          },
          "output_tokens": {
            "type": "integer",
            "title": "Output Tokens"
          },
          "credit_cost": {
            "type": "number",
            "title": "Credit Cost"
          }
        }
      },
      "UsagePeriod": {
        "type": "object",
        "title": "UsagePeriod",
        "properties": {
          "models": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ModelUsageBreakdown"
            },
            "title": "Models"
          },
          "total_input_tokens": {
            "type": "integer",
            "title": "Total Input Tokens"
          },
          "total_output_tokens": {
            "type": "integer",
            "title": "Total Output Tokens"
          },
          "total_credit_cost": {
            "type": "number",
            "title": "Total Credit Cost"
          }
        }
      },
      "KeyUsageEntry": {
        "type": "object",
        "title": "KeyUsageEntry",
        "properties": {
          "api_key_id": {
            "type": "string",
            "format": "uuid",
            "title": "API Key ID"
          },
          "description": {
            "type": "string",
            "title": "Description"
          },
          "display": {
            "type": "string",
            "title": "Display"
          },
          "today": {
            "$ref": "#/components/schemas/UsagePeriod",
            "title": "Today"
          },
          "all_time": {
            "$ref": "#/components/schemas/UsagePeriod",
            "title": "All Time"
          }
        }
      },
      "UsageTotals": {
        "type": "object",
        "title": "UsageTotals",
        "properties": {
          "today_credit_cost": {
            "type": "number",
            "title": "Today Credit Cost"
          },
          "all_time_credit_cost": {
            "type": "number",
            "title": "All Time Credit Cost"
          }
        }
      },
      "AllKeysUsageData": {
        "type": "object",
        "title": "AllKeysUsageData",
        "properties": {
          "keys": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/KeyUsageEntry"
            },
            "title": "Keys"
          },
          "totals": {
            "$ref": "#/components/schemas/UsageTotals"
          }
        }
      },
      "AllKeysUsageResponse": {
        "type": "object",
        "title": "AllKeysUsageResponse",
        "properties": {
          "status": {
            "type": "string",
            "example": "succeeded"
          },
          "data": {
            "$ref": "#/components/schemas/AllKeysUsageData"
          }
        }
      }
    }
  }
}