Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:A616567126 GPT WEB JAVA GptKeyController

From Leeroopedia
Knowledge Sources
Domains Admin_API, GPT_Key_Management
Last Updated 2026-10-13 00:00 GMT

Overview

Concrete REST controller for managing OpenAI API keys and querying billing/usage information with proxy support.

Description

The GptKeyController exposes endpoints under `/sys/gpt/key` for paginated key queries, adding keys, deleting keys, updating key state, and querying OpenAI billing information. The `billing` endpoint queries both the subscription endpoint for `hard_limit_usd` and the usage endpoint for `total_usage`, with optional HTTP proxy support based on system config.

Usage

Use this controller when building the admin GPT key management interface, including monitoring API key billing and usage.

Code Reference

Source Location

Signature

@RestController
@RequestMapping("/sys/gpt/key")
public class GptKeyController {

    @RequestMapping(value = "/queryPage", method = RequestMethod.POST)
    public B<Page<GptKeyQueryRes>> queryPage(@Validated @RequestBody BasePageHelper basePageHelper);

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public B<Void> add(@Validated @RequestBody GptKeyAddReq req);

    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public B<Void> delete(@Validated @RequestBody BaseDeleteEntity req);

    @RequestMapping(value = "/updateState", method = RequestMethod.POST)
    public B updateState(@Validated @RequestBody GptKeyUpdateStateReq req);

    @PostMapping(value = "/billing")
    public B<GptBillingRes> billing(@Validated @RequestBody GptBillingReq req);
}

Import

import com.intelligent.bot.api.sys.admin.GptKeyController;

I/O Contract

Inputs

Name Type Required Description
basePageHelper BasePageHelper Yes (query) Pagination params
req GptKeyAddReq Yes (add) API key string and description
req GptKeyUpdateStateReq Yes (update) Key ID and new state
req GptBillingReq Yes (billing) API key to query

Outputs

Name Type Description
queryPage B<Page<GptKeyQueryRes>> Paginated GPT key list
billing B<GptBillingRes> hard_limit_usd and total_usage

Usage Examples

Query Key Billing

// POST /sys/gpt/key/billing
{
    "key": "sk-xxxxxxxxxxxx"
}
// Response: { "hardLimitUsd": 120.00, "totalUsage": 0.53 }

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment