docs: update swagger specs for provider-groups and api-keys refactor

Regenerate OpenAPI documentation to reflect the architectural split
of Provider into ProviderGroup and APIKey models:

- Replace /admin/providers endpoints with /admin/provider-groups
- Add new /admin/api-keys CRUD and batch endpoints
- Update BindingDTO to use group_id instead of route_group
- Remove provider-specific DTOs (ProviderCustomCreateDTO, ProviderPresetCreateDTO, ProviderGoogleCreateDTO)
- Add APIKeyDTO and ProviderGroupDTO definitions
- Update model definitions for APIKey, Binding, and ProviderGroup
This commit is contained in:
zenfun
2025-12-24 02:20:32 +08:00
parent dea8363e41
commit d731e42ae5
3 changed files with 1078 additions and 1350 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -3,20 +3,39 @@ definitions:
gin.H: gin.H:
additionalProperties: {} additionalProperties: {}
type: object type: object
github_com_ez-api_ez-api_internal_dto.APIKeyDTO:
properties:
api_key:
type: string
auto_ban:
type: boolean
ban_reason:
type: string
ban_until:
type: string
group_id:
type: integer
status:
type: string
weight:
type: integer
type: object
github_com_ez-api_ez-api_internal_dto.BindingDTO: github_com_ez-api_ez-api_internal_dto.BindingDTO:
properties: properties:
group_id:
type: integer
namespace: namespace:
type: string type: string
public_model: public_model:
type: string type: string
route_group:
type: string
selector_type: selector_type:
type: string type: string
selector_value: selector_value:
type: string type: string
status: status:
type: string type: string
weight:
type: integer
type: object type: object
github_com_ez-api_ez-api_internal_dto.ModelDTO: github_com_ez-api_ez-api_internal_dto.ModelDTO:
properties: properties:
@@ -39,15 +58,13 @@ definitions:
supports_vision: supports_vision:
type: boolean type: boolean
type: object type: object
github_com_ez-api_ez-api_internal_dto.ProviderCustomCreateDTO: github_com_ez-api_ez-api_internal_dto.ProviderGroupDTO:
properties: properties:
api_key:
type: string
auto_ban:
type: boolean
base_url: base_url:
type: string type: string
group: google_location:
type: string
google_project:
type: string type: string
models: models:
items: items:
@@ -57,10 +74,10 @@ definitions:
type: string type: string
status: status:
type: string type: string
weight: type:
type: integer type: string
type: object type: object
github_com_ez-api_ez-api_internal_dto.ProviderDTO: github_com_ez-api_ez-api_internal_model.APIKey:
properties: properties:
api_key: api_key:
type: string type: string
@@ -70,87 +87,18 @@ definitions:
type: string type: string
ban_until: ban_until:
type: string type: string
base_url: createdAt:
type: string type: string
google_location: deletedAt:
type: string $ref: '#/definitions/gorm.DeletedAt'
google_project: group_id:
type: string
group:
type: string
models:
description: List of supported model names
items:
type: string
type: array
name:
type: string
skip_routing:
description: Optional control params
type: boolean
status:
type: string
type:
type: string
weight:
type: integer type: integer
type: object id:
github_com_ez-api_ez-api_internal_dto.ProviderGoogleCreateDTO:
properties:
api_key:
description: Gemini API
type: string
auto_ban:
type: boolean
google_location:
type: string
google_project:
description: Vertex
type: string
group:
type: string
models:
items:
type: string
type: array
name:
description: Optional fields.
type: string
status:
type: string
type:
description: |-
Type must be a Google-family provider type, e.g.:
- gemini/google/aistudio (Gemini API)
- vertex/vertex-express (Vertex)
type: string
weight:
type: integer type: integer
type: object
github_com_ez-api_ez-api_internal_dto.ProviderPresetCreateDTO:
properties:
api_key:
type: string
auto_ban:
type: boolean
google_location:
type: string
google_project:
type: string
group:
type: string
models:
items:
type: string
type: array
name:
description: Optional fields.
type: string
preset:
description: openai | anthropic | gemini
type: string
status: status:
type: string type: string
updatedAt:
type: string
weight: weight:
type: integer type: integer
type: object type: object
@@ -160,14 +108,14 @@ definitions:
type: string type: string
deletedAt: deletedAt:
$ref: '#/definitions/gorm.DeletedAt' $ref: '#/definitions/gorm.DeletedAt'
group_id:
type: integer
id: id:
type: integer type: integer
namespace: namespace:
type: string type: string
public_model: public_model:
type: string type: string
route_group:
type: string
selector_type: selector_type:
type: string type: string
selector_value: selector_value:
@@ -176,6 +124,8 @@ definitions:
type: string type: string
updatedAt: updatedAt:
type: string type: string
weight:
type: integer
type: object type: object
github_com_ez-api_ez-api_internal_model.LogRecord: github_com_ez-api_ez-api_internal_model.LogRecord:
properties: properties:
@@ -270,19 +220,8 @@ definitions:
updatedAt: updatedAt:
type: string type: string
type: object type: object
github_com_ez-api_ez-api_internal_model.Provider: github_com_ez-api_ez-api_internal_model.ProviderGroup:
properties: properties:
api_key:
type: string
auto_ban:
description: whether DP-triggered disable is allowed
type: boolean
ban_reason:
description: reason for current disable
type: string
ban_until:
description: optional TTL for disable
type: string
base_url: base_url:
type: string type: string
createdAt: createdAt:
@@ -293,27 +232,20 @@ definitions:
type: string type: string
google_project: google_project:
type: string type: string
group:
description: routing group/tier
type: string
id: id:
type: integer type: integer
models: models:
description: comma-separated list of supported models (e.g. "gpt-4,gpt-3.5-turbo") description: comma-separated list of supported models
type: string type: string
name: name:
type: string type: string
status: status:
description: active, auto_disabled, manual_disabled
type: string type: string
type: type:
description: openai, anthropic, etc. description: openai, anthropic, gemini
type: string type: string
updatedAt: updatedAt:
type: string type: string
weight:
description: routing weight inside route_group
type: integer
type: object type: object
github_com_ez-api_ez-api_internal_service.HealthStatus: github_com_ez-api_ez-api_internal_service.HealthStatus:
properties: properties:
@@ -822,17 +754,6 @@ definitions:
$ref: '#/definitions/internal_api.statsFlushEntry' $ref: '#/definitions/internal_api.statsFlushEntry'
type: array type: array
type: object type: object
internal_api.testProviderResponse:
properties:
body:
type: string
ok:
type: boolean
status_code:
type: integer
url:
type: string
type: object
modelcap.Meta: modelcap.Meta:
properties: properties:
checksum: checksum:
@@ -885,6 +806,208 @@ info:
title: EZ-API Control Plane title: EZ-API Control Plane
version: 0.0.1 version: 0.0.1
paths: paths:
/admin/api-keys:
get:
description: List API keys
parameters:
- description: page (1-based)
in: query
name: page
type: integer
- description: limit (default 50, max 200)
in: query
name: limit
type: integer
- description: filter by group_id
in: query
name: group_id
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
items:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_model.APIKey'
type: array
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/gin.H'
security:
- AdminAuth: []
summary: List API keys
tags:
- admin
post:
consumes:
- application/json
description: Create an API key for a provider group
parameters:
- description: API key payload
in: body
name: key
required: true
schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_dto.APIKeyDTO'
produces:
- application/json
responses:
"201":
description: Created
schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_model.APIKey'
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/gin.H'
security:
- AdminAuth: []
summary: Create an API key
tags:
- admin
/admin/api-keys/{id}:
delete:
description: Delete an API key
parameters:
- description: APIKey ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/gin.H'
"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: Delete API key
tags:
- admin
get:
description: Get an API key by id
parameters:
- description: APIKey ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_model.APIKey'
"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: Get API key
tags:
- admin
put:
consumes:
- application/json
description: Update an API key
parameters:
- description: APIKey ID
in: path
name: id
required: true
type: integer
- description: API key payload
in: body
name: key
required: true
schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_dto.APIKeyDTO'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_model.APIKey'
"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 API key
tags:
- admin
/admin/api-keys/batch:
post:
consumes:
- application/json
description: Batch delete or status update for api keys
parameters:
- description: Batch payload
in: body
name: request
required: true
schema:
$ref: '#/definitions/internal_api.BatchActionRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/internal_api.BatchResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/gin.H'
security:
- AdminAuth: []
summary: Batch api keys
tags:
- admin
/admin/bindings: /admin/bindings:
get: get:
description: List all configured bindings description: List all configured bindings
@@ -897,7 +1020,7 @@ paths:
in: query in: query
name: limit name: limit
type: integer type: integer
- description: search by namespace/public_model/route_group - description: search by namespace/public_model
in: query in: query
name: search name: search
type: string type: string
@@ -922,7 +1045,7 @@ paths:
post: post:
consumes: consumes:
- application/json - application/json
description: Create a new (namespace, public_model) binding to a route group description: Create a new (namespace, public_model) binding to a provider group
and selector and selector
parameters: parameters:
- description: Binding Info - description: Binding Info
@@ -2247,9 +2370,9 @@ paths:
summary: List operation logs summary: List operation logs
tags: tags:
- admin - admin
/admin/providers: /admin/provider-groups:
get: get:
description: List all configured upstream providers description: List all provider groups
parameters: parameters:
- description: page (1-based) - description: page (1-based)
in: query in: query
@@ -2259,7 +2382,7 @@ paths:
in: query in: query
name: limit name: limit
type: integer type: integer
- description: search by name/type/base_url/group - description: search by name/type
in: query in: query
name: search name: search
type: string type: string
@@ -2270,7 +2393,7 @@ paths:
description: OK description: OK
schema: schema:
items: items:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_model.Provider' $ref: '#/definitions/github_com_ez-api_ez-api_internal_model.ProviderGroup'
type: array type: array
"500": "500":
description: Internal Server Error description: Internal Server Error
@@ -2278,27 +2401,27 @@ paths:
$ref: '#/definitions/gin.H' $ref: '#/definitions/gin.H'
security: security:
- AdminAuth: [] - AdminAuth: []
summary: List providers summary: List provider groups
tags: tags:
- admin - admin
post: post:
consumes: consumes:
- application/json - application/json
description: Register a new upstream AI provider description: Create a provider group definition
parameters: parameters:
- description: Provider Info - description: Provider group payload
in: body in: body
name: provider name: group
required: true required: true
schema: schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_dto.ProviderDTO' $ref: '#/definitions/github_com_ez-api_ez-api_internal_dto.ProviderGroupDTO'
produces: produces:
- application/json - application/json
responses: responses:
"201": "201":
description: Created description: Created
schema: schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_model.Provider' $ref: '#/definitions/github_com_ez-api_ez-api_internal_model.ProviderGroup'
"400": "400":
description: Bad Request description: Bad Request
schema: schema:
@@ -2309,15 +2432,14 @@ paths:
$ref: '#/definitions/gin.H' $ref: '#/definitions/gin.H'
security: security:
- AdminAuth: [] - AdminAuth: []
summary: Create a new provider summary: Create a provider group
tags: tags:
- admin - admin
/admin/providers/{id}: /admin/provider-groups/{id}:
delete: delete:
description: Deletes a provider and triggers a full snapshot sync to avoid stale description: Delete a provider group and its api keys/bindings
routing
parameters: parameters:
- description: Provider ID - description: ProviderGroup ID
in: path in: path
name: id name: id
required: true required: true
@@ -2343,13 +2465,13 @@ paths:
$ref: '#/definitions/gin.H' $ref: '#/definitions/gin.H'
security: security:
- AdminAuth: [] - AdminAuth: []
summary: Delete provider summary: Delete provider group
tags: tags:
- admin - admin
get: get:
description: Get a provider by id description: Get a provider group by id
parameters: parameters:
- description: Provider ID - description: ProviderGroup ID
in: path in: path
name: id name: id
required: true required: true
@@ -2360,7 +2482,7 @@ paths:
"200": "200":
description: OK description: OK
schema: schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_model.Provider' $ref: '#/definitions/github_com_ez-api_ez-api_internal_model.ProviderGroup'
"400": "400":
description: Bad Request description: Bad Request
schema: schema:
@@ -2375,32 +2497,32 @@ paths:
$ref: '#/definitions/gin.H' $ref: '#/definitions/gin.H'
security: security:
- AdminAuth: [] - AdminAuth: []
summary: Get provider summary: Get provider group
tags: tags:
- admin - admin
put: put:
consumes: consumes:
- application/json - application/json
description: Update provider attributes including status/auto-ban flags description: Update a provider group
parameters: parameters:
- description: Provider ID - description: ProviderGroup ID
in: path in: path
name: id name: id
required: true required: true
type: integer type: integer
- description: Provider Info - description: Provider group payload
in: body in: body
name: provider name: group
required: true required: true
schema: schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_dto.ProviderDTO' $ref: '#/definitions/github_com_ez-api_ez-api_internal_dto.ProviderGroupDTO'
produces: produces:
- application/json - application/json
responses: responses:
"200": "200":
description: OK description: OK
schema: schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_model.Provider' $ref: '#/definitions/github_com_ez-api_ez-api_internal_model.ProviderGroup'
"400": "400":
description: Bad Request description: Bad Request
schema: schema:
@@ -2415,205 +2537,7 @@ paths:
$ref: '#/definitions/gin.H' $ref: '#/definitions/gin.H'
security: security:
- AdminAuth: [] - AdminAuth: []
summary: Update a provider summary: Update provider group
tags:
- admin
/admin/providers/{id}/fetch-models:
post:
description: Calls upstream /models (or /v1/models) and updates provider model
list
parameters:
- description: Provider ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/gin.H'
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
"404":
description: Not Found
schema:
$ref: '#/definitions/gin.H'
"502":
description: Bad Gateway
schema:
$ref: '#/definitions/gin.H'
security:
- AdminAuth: []
summary: Fetch models from provider
tags:
- admin
/admin/providers/{id}/test:
post:
description: Performs a lightweight upstream request to verify the provider
configuration
parameters:
- description: Provider ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/internal_api.testProviderResponse'
"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: Test provider connectivity
tags:
- admin
/admin/providers/batch:
post:
consumes:
- application/json
description: Batch delete or status update for providers
parameters:
- description: Batch payload
in: body
name: request
required: true
schema:
$ref: '#/definitions/internal_api.BatchActionRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/internal_api.BatchResponse'
"400":
description: Bad Request
schema:
$ref: '#/definitions/gin.H'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/gin.H'
security:
- AdminAuth: []
summary: Batch providers
tags:
- admin
/admin/providers/custom:
post:
consumes:
- application/json
description: Create an OpenAI-compatible provider (base_url + api_key required)
parameters:
- description: Provider custom payload
in: body
name: provider
required: true
schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_dto.ProviderCustomCreateDTO'
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 custom provider
tags:
- admin
/admin/providers/google:
post:
consumes:
- application/json
description: Create a Google SDK provider (Gemini API key or Vertex project/location);
base_url is not used
parameters:
- description: Google provider payload
in: body
name: provider
required: true
schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_dto.ProviderGoogleCreateDTO'
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 Google SDK provider
tags:
- admin
/admin/providers/preset:
post:
consumes:
- application/json
description: Create an official OpenAI/Anthropic provider (only api_key is typically
required)
parameters:
- description: Provider preset payload
in: body
name: provider
required: true
schema:
$ref: '#/definitions/github_com_ez-api_ez-api_internal_dto.ProviderPresetCreateDTO'
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 preset provider
tags: tags:
- admin - admin
/admin/stats: /admin/stats: