feat: Add Swagger documentation for admin and master API endpoints

- Added Swagger documentation for the following admin endpoints:
  - Create a new master tenant
  - Create a new provider
  - Register a new model
  - List all models
  - Update a model
  - Force sync snapshot
  - Ingest logs

- Added Swagger documentation for the master endpoint:
  - Issue a child key

- Updated go.mod and go.sum to include necessary dependencies for Swagger.
This commit is contained in:
2025-12-05 15:01:35 +08:00
parent 25e5e105b3
commit 770a9fef2b
10 changed files with 2017 additions and 26 deletions

687
docs/docs.go Normal file
View File

@@ -0,0 +1,687 @@
// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs
import "github.com/swaggo/swag"
const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "API Support",
"url": "http://www.swagger.io/support",
"email": "support@swagger.io"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/admin/masters": {
"post": {
"security": [
{
"AdminAuth": []
}
],
"description": "Create a new master account (tenant)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Create a new master tenant",
"parameters": [
{
"description": "Master Info",
"name": "master",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/internal_api.CreateMasterRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/models": {
"get": {
"security": [
{
"AdminAuth": []
}
],
"description": "Get a list of all registered models",
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "List all models",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_model.Model"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
},
"post": {
"security": [
{
"AdminAuth": []
}
],
"description": "Register a supported model with its capabilities",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Register a new model",
"parameters": [
{
"description": "Model Info",
"name": "model",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_dto.ModelDTO"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_model.Model"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/models/{id}": {
"put": {
"security": [
{
"AdminAuth": []
}
],
"description": "Update an existing model's configuration",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Update a model",
"parameters": [
{
"type": "integer",
"description": "Model ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Model Info",
"name": "model",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_dto.ModelDTO"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_model.Model"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/providers": {
"post": {
"security": [
{
"AdminAuth": []
}
],
"description": "Register a new upstream AI provider",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Create a new provider",
"parameters": [
{
"description": "Provider Info",
"name": "provider",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_dto.ProviderDTO"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_model.Provider"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/sync/snapshot": {
"post": {
"security": [
{
"AdminAuth": []
}
],
"description": "Force full synchronization of DB state to Redis",
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Force sync snapshot",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/logs": {
"post": {
"description": "Internal endpoint for ingesting logs from Balancer",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Ingest logs",
"parameters": [
{
"description": "Log Record",
"name": "log",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_model.LogRecord"
}
}
],
"responses": {
"202": {
"description": "Accepted",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/v1/tokens": {
"post": {
"security": [
{
"MasterAuth": []
}
],
"description": "Issue a new access token (child key) for the authenticated master",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"master"
],
"summary": "Issue a child key",
"parameters": [
{
"description": "Key Request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/internal_api.IssueChildKeyRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
}
},
"definitions": {
"gin.H": {
"type": "object",
"additionalProperties": {}
},
"github_com_ez-api_ez-api_internal_dto.ModelDTO": {
"type": "object",
"properties": {
"context_window": {
"type": "integer"
},
"cost_per_token": {
"type": "number"
},
"max_output_tokens": {
"type": "integer"
},
"name": {
"type": "string"
},
"supports_fim": {
"type": "boolean"
},
"supports_functions": {
"type": "boolean"
},
"supports_tool_choice": {
"type": "boolean"
},
"supports_vision": {
"type": "boolean"
}
}
},
"github_com_ez-api_ez-api_internal_dto.ProviderDTO": {
"type": "object",
"properties": {
"api_key": {
"type": "string"
},
"base_url": {
"type": "string"
},
"group": {
"type": "string"
},
"models": {
"description": "List of supported model names",
"type": "array",
"items": {
"type": "string"
}
},
"name": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"github_com_ez-api_ez-api_internal_model.LogRecord": {
"type": "object",
"properties": {
"audit_reason": {
"type": "string"
},
"client_ip": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"deletedAt": {
"$ref": "#/definitions/gorm.DeletedAt"
},
"error_message": {
"type": "string"
},
"group": {
"type": "string"
},
"id": {
"type": "integer"
},
"key_id": {
"type": "integer"
},
"latency_ms": {
"type": "integer"
},
"model": {
"type": "string"
},
"request_body": {
"description": "optional, only when audit triggered",
"type": "string"
},
"request_size": {
"type": "integer"
},
"response_body": {
"description": "optional, only when audit triggered",
"type": "string"
},
"response_size": {
"type": "integer"
},
"status_code": {
"type": "integer"
},
"tokens_in": {
"type": "integer"
},
"tokens_out": {
"type": "integer"
},
"updatedAt": {
"type": "string"
}
}
},
"github_com_ez-api_ez-api_internal_model.Model": {
"type": "object",
"properties": {
"context_window": {
"type": "integer"
},
"cost_per_token": {
"type": "number"
},
"createdAt": {
"type": "string"
},
"deletedAt": {
"$ref": "#/definitions/gorm.DeletedAt"
},
"id": {
"type": "integer"
},
"max_output_tokens": {
"type": "integer"
},
"name": {
"type": "string"
},
"supports_fim": {
"type": "boolean"
},
"supports_functions": {
"type": "boolean"
},
"supports_tool_choice": {
"type": "boolean"
},
"supports_vision": {
"type": "boolean"
},
"updatedAt": {
"type": "string"
}
}
},
"github_com_ez-api_ez-api_internal_model.Provider": {
"type": "object",
"properties": {
"api_key": {
"type": "string"
},
"base_url": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"deletedAt": {
"$ref": "#/definitions/gorm.DeletedAt"
},
"group": {
"description": "routing group/tier",
"type": "string"
},
"id": {
"type": "integer"
},
"models": {
"description": "comma-separated list of supported models (e.g. \"gpt-4,gpt-3.5-turbo\")",
"type": "string"
},
"name": {
"type": "string"
},
"type": {
"description": "openai, anthropic, etc.",
"type": "string"
},
"updatedAt": {
"type": "string"
}
}
},
"gorm.DeletedAt": {
"type": "object",
"properties": {
"time": {
"type": "string"
},
"valid": {
"description": "Valid is true if Time is not NULL",
"type": "boolean"
}
}
},
"internal_api.CreateMasterRequest": {
"type": "object",
"required": [
"group",
"name"
],
"properties": {
"global_qps": {
"type": "integer"
},
"group": {
"type": "string"
},
"max_child_keys": {
"type": "integer"
},
"name": {
"type": "string"
}
}
},
"internal_api.IssueChildKeyRequest": {
"type": "object",
"properties": {
"group": {
"type": "string"
},
"scopes": {
"type": "string"
}
}
}
},
"securityDefinitions": {
"AdminAuth": {
"type": "apiKey",
"name": "Authorization",
"in": "header"
},
"MasterAuth": {
"type": "apiKey",
"name": "Authorization",
"in": "header"
}
}
}`
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "0.0.1",
Host: "localhost:8080",
BasePath: "/",
Schemes: []string{},
Title: "EZ-API Control Plane",
Description: "Management API for EZ-API Gateway system.",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}
func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}

663
docs/swagger.json Normal file
View File

@@ -0,0 +1,663 @@
{
"swagger": "2.0",
"info": {
"description": "Management API for EZ-API Gateway system.",
"title": "EZ-API Control Plane",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "API Support",
"url": "http://www.swagger.io/support",
"email": "support@swagger.io"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
},
"version": "0.0.1"
},
"host": "localhost:8080",
"basePath": "/",
"paths": {
"/admin/masters": {
"post": {
"security": [
{
"AdminAuth": []
}
],
"description": "Create a new master account (tenant)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Create a new master tenant",
"parameters": [
{
"description": "Master Info",
"name": "master",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/internal_api.CreateMasterRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/models": {
"get": {
"security": [
{
"AdminAuth": []
}
],
"description": "Get a list of all registered models",
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "List all models",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_model.Model"
}
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
},
"post": {
"security": [
{
"AdminAuth": []
}
],
"description": "Register a supported model with its capabilities",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Register a new model",
"parameters": [
{
"description": "Model Info",
"name": "model",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_dto.ModelDTO"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_model.Model"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/models/{id}": {
"put": {
"security": [
{
"AdminAuth": []
}
],
"description": "Update an existing model's configuration",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Update a model",
"parameters": [
{
"type": "integer",
"description": "Model ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "Model Info",
"name": "model",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_dto.ModelDTO"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_model.Model"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/providers": {
"post": {
"security": [
{
"AdminAuth": []
}
],
"description": "Register a new upstream AI provider",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Create a new provider",
"parameters": [
{
"description": "Provider Info",
"name": "provider",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_dto.ProviderDTO"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_model.Provider"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/admin/sync/snapshot": {
"post": {
"security": [
{
"AdminAuth": []
}
],
"description": "Force full synchronization of DB state to Redis",
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "Force sync snapshot",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/logs": {
"post": {
"description": "Internal endpoint for ingesting logs from Balancer",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"system"
],
"summary": "Ingest logs",
"parameters": [
{
"description": "Log Record",
"name": "log",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/github_com_ez-api_ez-api_internal_model.LogRecord"
}
}
],
"responses": {
"202": {
"description": "Accepted",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
},
"/v1/tokens": {
"post": {
"security": [
{
"MasterAuth": []
}
],
"description": "Issue a new access token (child key) for the authenticated master",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"master"
],
"summary": "Issue a child key",
"parameters": [
{
"description": "Key Request",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/internal_api.IssueChildKeyRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"403": {
"description": "Forbidden",
"schema": {
"$ref": "#/definitions/gin.H"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/gin.H"
}
}
}
}
}
},
"definitions": {
"gin.H": {
"type": "object",
"additionalProperties": {}
},
"github_com_ez-api_ez-api_internal_dto.ModelDTO": {
"type": "object",
"properties": {
"context_window": {
"type": "integer"
},
"cost_per_token": {
"type": "number"
},
"max_output_tokens": {
"type": "integer"
},
"name": {
"type": "string"
},
"supports_fim": {
"type": "boolean"
},
"supports_functions": {
"type": "boolean"
},
"supports_tool_choice": {
"type": "boolean"
},
"supports_vision": {
"type": "boolean"
}
}
},
"github_com_ez-api_ez-api_internal_dto.ProviderDTO": {
"type": "object",
"properties": {
"api_key": {
"type": "string"
},
"base_url": {
"type": "string"
},
"group": {
"type": "string"
},
"models": {
"description": "List of supported model names",
"type": "array",
"items": {
"type": "string"
}
},
"name": {
"type": "string"
},
"type": {
"type": "string"
}
}
},
"github_com_ez-api_ez-api_internal_model.LogRecord": {
"type": "object",
"properties": {
"audit_reason": {
"type": "string"
},
"client_ip": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"deletedAt": {
"$ref": "#/definitions/gorm.DeletedAt"
},
"error_message": {
"type": "string"
},
"group": {
"type": "string"
},
"id": {
"type": "integer"
},
"key_id": {
"type": "integer"
},
"latency_ms": {
"type": "integer"
},
"model": {
"type": "string"
},
"request_body": {
"description": "optional, only when audit triggered",
"type": "string"
},
"request_size": {
"type": "integer"
},
"response_body": {
"description": "optional, only when audit triggered",
"type": "string"
},
"response_size": {
"type": "integer"
},
"status_code": {
"type": "integer"
},
"tokens_in": {
"type": "integer"
},
"tokens_out": {
"type": "integer"
},
"updatedAt": {
"type": "string"
}
}
},
"github_com_ez-api_ez-api_internal_model.Model": {
"type": "object",
"properties": {
"context_window": {
"type": "integer"
},
"cost_per_token": {
"type": "number"
},
"createdAt": {
"type": "string"
},
"deletedAt": {
"$ref": "#/definitions/gorm.DeletedAt"
},
"id": {
"type": "integer"
},
"max_output_tokens": {
"type": "integer"
},
"name": {
"type": "string"
},
"supports_fim": {
"type": "boolean"
},
"supports_functions": {
"type": "boolean"
},
"supports_tool_choice": {
"type": "boolean"
},
"supports_vision": {
"type": "boolean"
},
"updatedAt": {
"type": "string"
}
}
},
"github_com_ez-api_ez-api_internal_model.Provider": {
"type": "object",
"properties": {
"api_key": {
"type": "string"
},
"base_url": {
"type": "string"
},
"createdAt": {
"type": "string"
},
"deletedAt": {
"$ref": "#/definitions/gorm.DeletedAt"
},
"group": {
"description": "routing group/tier",
"type": "string"
},
"id": {
"type": "integer"
},
"models": {
"description": "comma-separated list of supported models (e.g. \"gpt-4,gpt-3.5-turbo\")",
"type": "string"
},
"name": {
"type": "string"
},
"type": {
"description": "openai, anthropic, etc.",
"type": "string"
},
"updatedAt": {
"type": "string"
}
}
},
"gorm.DeletedAt": {
"type": "object",
"properties": {
"time": {
"type": "string"
},
"valid": {
"description": "Valid is true if Time is not NULL",
"type": "boolean"
}
}
},
"internal_api.CreateMasterRequest": {
"type": "object",
"required": [
"group",
"name"
],
"properties": {
"global_qps": {
"type": "integer"
},
"group": {
"type": "string"
},
"max_child_keys": {
"type": "integer"
},
"name": {
"type": "string"
}
}
},
"internal_api.IssueChildKeyRequest": {
"type": "object",
"properties": {
"group": {
"type": "string"
},
"scopes": {
"type": "string"
}
}
}
},
"securityDefinitions": {
"AdminAuth": {
"type": "apiKey",
"name": "Authorization",
"in": "header"
},
"MasterAuth": {
"type": "apiKey",
"name": "Authorization",
"in": "header"
}
}
}

431
docs/swagger.yaml Normal file
View File

@@ -0,0 +1,431 @@
basePath: /
definitions:
gin.H:
additionalProperties: {}
type: object
github_com_ez-api_ez-api_internal_dto.ModelDTO:
properties:
context_window:
type: integer
cost_per_token:
type: number
max_output_tokens:
type: integer
name:
type: string
supports_fim:
type: boolean
supports_functions:
type: boolean
supports_tool_choice:
type: boolean
supports_vision:
type: boolean
type: object
github_com_ez-api_ez-api_internal_dto.ProviderDTO:
properties:
api_key:
type: string
base_url:
type: string
group:
type: string
models:
description: List of supported model names
items:
type: string
type: array
name:
type: string
type:
type: string
type: object
github_com_ez-api_ez-api_internal_model.LogRecord:
properties:
audit_reason:
type: string
client_ip:
type: string
createdAt:
type: string
deletedAt:
$ref: '#/definitions/gorm.DeletedAt'
error_message:
type: string
group:
type: string
id:
type: integer
key_id:
type: integer
latency_ms:
type: integer
model:
type: string
request_body:
description: optional, only when audit triggered
type: string
request_size:
type: integer
response_body:
description: optional, only when audit triggered
type: string
response_size:
type: integer
status_code:
type: integer
tokens_in:
type: integer
tokens_out:
type: integer
updatedAt:
type: string
type: object
github_com_ez-api_ez-api_internal_model.Model:
properties:
context_window:
type: integer
cost_per_token:
type: number
createdAt:
type: string
deletedAt:
$ref: '#/definitions/gorm.DeletedAt'
id:
type: integer
max_output_tokens:
type: integer
name:
type: string
supports_fim:
type: boolean
supports_functions:
type: boolean
supports_tool_choice:
type: boolean
supports_vision:
type: boolean
updatedAt:
type: string
type: object
github_com_ez-api_ez-api_internal_model.Provider:
properties:
api_key:
type: string
base_url:
type: string
createdAt:
type: string
deletedAt:
$ref: '#/definitions/gorm.DeletedAt'
group:
description: routing group/tier
type: string
id:
type: integer
models:
description: comma-separated list of supported models (e.g. "gpt-4,gpt-3.5-turbo")
type: string
name:
type: string
type:
description: openai, anthropic, etc.
type: string
updatedAt:
type: string
type: object
gorm.DeletedAt:
properties:
time:
type: string
valid:
description: Valid is true if Time is not NULL
type: boolean
type: object
internal_api.CreateMasterRequest:
properties:
global_qps:
type: integer
group:
type: string
max_child_keys:
type: integer
name:
type: string
required:
- group
- name
type: object
internal_api.IssueChildKeyRequest:
properties:
group:
type: string
scopes:
type: string
type: object
host: localhost:8080
info:
contact:
email: support@swagger.io
name: API Support
url: http://www.swagger.io/support
description: Management API for EZ-API Gateway system.
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
termsOfService: http://swagger.io/terms/
title: EZ-API Control Plane
version: 0.0.1
paths:
/admin/masters:
post:
consumes:
- application/json
description: Create a new master account (tenant)
parameters:
- description: Master Info
in: body
name: master
required: true
schema:
$ref: '#/definitions/internal_api.CreateMasterRequest'
produces:
- application/json
responses:
"201":
description: Created
schema:
$ref: '#/definitions/gin.H'
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/gin.H'
security:
- AdminAuth: []
summary: Create a new master tenant
tags:
- admin
/admin/models:
get:
description: Get a list of all registered models
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_model.Model'
type: array
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/gin.H'
security:
- AdminAuth: []
summary: List all models
tags:
- admin
post:
consumes:
- application/json
description: Register a supported model with its capabilities
parameters:
- description: Model Info
in: body
name: model
required: true
schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_dto.ModelDTO'
produces:
- application/json
responses:
"201":
description: Created
schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_model.Model'
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/gin.H'
security:
- AdminAuth: []
summary: Register a new model
tags:
- admin
/admin/models/{id}:
put:
consumes:
- application/json
description: Update an existing model's configuration
parameters:
- description: Model ID
in: path
name: id
required: true
type: integer
- description: Model Info
in: body
name: model
required: true
schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_dto.ModelDTO'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_model.Model'
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
"404":
description: Not Found
schema:
$ref: '#/definitions/gin.H'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/gin.H'
security:
- AdminAuth: []
summary: Update a model
tags:
- admin
/admin/providers:
post:
consumes:
- application/json
description: Register a new upstream AI provider
parameters:
- description: Provider Info
in: body
name: provider
required: true
schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_dto.ProviderDTO'
produces:
- application/json
responses:
"201":
description: Created
schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_model.Provider'
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/gin.H'
security:
- AdminAuth: []
summary: Create a new provider
tags:
- admin
/admin/sync/snapshot:
post:
description: Force full synchronization of DB state to Redis
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/gin.H'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/gin.H'
security:
- AdminAuth: []
summary: Force sync snapshot
tags:
- admin
/logs:
post:
consumes:
- application/json
description: Internal endpoint for ingesting logs from Balancer
parameters:
- description: Log Record
in: body
name: log
required: true
schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_model.LogRecord'
produces:
- application/json
responses:
"202":
description: Accepted
schema:
$ref: '#/definitions/gin.H'
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
summary: Ingest logs
tags:
- system
/v1/tokens:
post:
consumes:
- application/json
description: Issue a new access token (child key) for the authenticated master
parameters:
- description: Key Request
in: body
name: request
required: true
schema:
$ref: '#/definitions/internal_api.IssueChildKeyRequest'
produces:
- application/json
responses:
"201":
description: Created
schema:
$ref: '#/definitions/gin.H'
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/gin.H'
"403":
description: Forbidden
schema:
$ref: '#/definitions/gin.H'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/gin.H'
security:
- MasterAuth: []
summary: Issue a child key
tags:
- master
securityDefinitions:
AdminAuth:
in: header
name: Authorization
type: apiKey
MasterAuth:
in: header
name: Authorization
type: apiKey
swagger: "2.0"