cherry-studio/packages/catalog/api/openapi.json
suyao 2593a427e0
refactor: update schemas and models for consistency and clarity
- Changed `perMillionTokens` to `per_million_tokens` in PricePerTokenSchema for snake_case consistency.
- Removed unused types from index.ts and simplified ProviderModelOverrideSchema by removing deprecated fields.
- Enhanced ModelConfigSchema to enforce unique capabilities and modalities, and made context_window and max_output_tokens optional.
- Updated ProviderConfigSchema to require at least one supported endpoint.
- Removed commented-out code and unused imports in route.ts for cleaner code.
- Added a cleanup script to remove deprecated fields from overrides.json.
- Implemented a new importer for AIHubMix models, transforming API data into the internal format.
- Created a utility for applying and validating model overrides, ensuring better error handling and warnings.
- Updated various scripts for better organization and clarity, including removing search models and generating AIHubMix models.
2025-12-08 22:47:16 +08:00

653 lines
17 KiB
JSON

{
"openapi": "3.0.3",
"info": {
"title": "Cherry Studio Catalog API",
"description": "REST API for managing AI models and providers catalog",
"version": "1.0.0",
"contact": {
"name": "Cherry Studio Team"
}
},
"servers": [
{
"url": "http://localhost:3000/api",
"description": "Development server"
}
],
"paths": {
"/catalog/models": {
"get": {
"summary": "List models with pagination and filtering",
"parameters": [
{
"name": "page",
"in": "query",
"schema": {
"type": "integer",
"minimum": 1,
"default": 1
}
},
{
"name": "limit",
"in": "query",
"schema": {
"type": "integer",
"minimum": 1,
"maximum": 100,
"default": 20
}
},
{
"name": "search",
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "capabilities",
"in": "query",
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
},
{
"name": "providers",
"in": "query",
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
],
"responses": {
"200": {
"description": "Paginated list of models",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PaginatedModels"
}
}
}
}
}
},
"put": {
"summary": "Update models configuration",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ModelsConfig"
}
}
}
},
"responses": {
"200": {
"description": "Models updated successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
}
}
}
}
}
}
}
}
},
"/catalog/models/{modelId}": {
"get": {
"summary": "Get specific model details",
"parameters": [
{
"name": "modelId",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Model details",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Model"
}
}
}
}
}
},
"put": {
"summary": "Update specific model",
"parameters": [
{
"name": "modelId",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Model"
}
}
}
},
"responses": {
"200": {
"description": "Model updated successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"model": {
"$ref": "#/components/schemas/Model"
}
}
}
}
}
}
}
}
},
"/catalog/providers": {
"get": {
"summary": "List providers with pagination and filtering",
"parameters": [
{
"name": "page",
"in": "query",
"schema": {
"type": "integer",
"minimum": 1,
"default": 1
}
},
{
"name": "limit",
"in": "query",
"schema": {
"type": "integer",
"minimum": 1,
"maximum": 100,
"default": 20
}
},
{
"name": "search",
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "authentication",
"in": "query",
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
],
"responses": {
"200": {
"description": "Paginated list of providers",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PaginatedProviders"
}
}
}
}
}
},
"put": {
"summary": "Update providers configuration",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProvidersConfig"
}
}
}
},
"responses": {
"200": {
"description": "Providers updated successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
}
}
}
}
}
}
}
}
},
"/catalog/providers/{providerId}": {
"get": {
"summary": "Get specific provider details",
"parameters": [
{
"name": "providerId",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Provider details",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Provider"
}
}
}
}
},
"put": {
"summary": "Update specific provider",
"parameters": [
{
"name": "providerId",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Provider"
}
}
}
},
"responses": {
"200": {
"description": "Provider updated successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"provider": {
"$ref": "#/components/schemas/Provider"
}
}
}
}
}
}
}
}
}
},
"/catalog/models/{modelId}/providers/{providerId}": {
"get": {
"summary": "Get model configuration as seen by specific provider",
"parameters": [
{
"name": "modelId",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "providerId",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Model configuration with provider-specific overrides applied",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Model"
}
}
}
}
}
},
"put": {
"summary": "Update model configuration for specific provider (auto-detects if override is needed)",
"parameters": [
{
"name": "modelId",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "providerId",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Model"
}
}
}
},
"responses": {
"200": {
"description": "Model configuration updated (override created/updated if needed)",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"updated": {
"type": "string",
"enum": ["base_model", "override", "override_updated", "override_removed"]
},
"model": {
"$ref": "#/components/schemas/Model"
}
}
}
}
}
}
}
}
},
"/catalog/stats": {
"get": {
"summary": "Get catalog statistics",
"responses": {
"200": {
"description": "Catalog statistics",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CatalogStats"
}
}
}
}
}
}
},
"components": {
"schemas": {
"Model": {
"type": "object",
"properties": {
"id": { "type": "string" },
"name": { "type": "string" },
"owned_by": { "type": "string" },
"capabilities": {
"type": "array",
"items": { "type": "string" }
},
"input_modalities": {
"type": "array",
"items": { "type": "string" }
},
"output_modalities": {
"type": "array",
"items": { "type": "string" }
},
"context_window": { "type": "integer" },
"max_output_tokens": { "type": "integer" },
"max_input_tokens": { "type": "integer" },
"pricing": {
"$ref": "#/components/schemas/Pricing"
},
"parameters": {
"$ref": "#/components/schemas/Parameters"
},
"endpoint_types": {
"type": "array",
"items": { "type": "string" }
},
"metadata": { "type": "object" }
}
},
"Provider": {
"type": "object",
"properties": {
"id": { "type": "string" },
"name": { "type": "string" },
"description": { "type": "string" },
"authentication": { "type": "string" },
"pricing_model": { "type": "string" },
"model_routing": { "type": "string" },
"behaviors": { "type": "object" },
"supported_endpoints": {
"type": "array",
"items": { "type": "string" }
},
"api_compatibility": { "type": "object" },
"special_config": { "type": "object" },
"documentation": { "type": "string" },
"website": { "type": "string" },
"deprecated": { "type": "boolean" },
"maintenance_mode": { "type": "boolean" },
"config_version": { "type": "string" },
"metadata": { "type": "object" }
}
},
"Override": {
"type": "object",
"properties": {
"provider_id": { "type": "string" },
"model_id": { "type": "string" },
"disabled": { "type": "boolean" },
"reason": { "type": "string" },
"last_updated": { "type": "string" },
"updated_by": { "type": "string" },
"priority": { "type": "integer" },
"limits": {
"type": "object",
"properties": {
"context_window": { "type": "integer" },
"max_output_tokens": { "type": "integer" }
}
},
"pricing": {
"$ref": "#/components/schemas/Pricing"
}
}
},
"Pricing": {
"type": "object",
"properties": {
"input": {
"type": "object",
"properties": {
"per_million_tokens": { "type": "number" },
"currency": { "type": "string" }
}
},
"output": {
"type": "object",
"properties": {
"per_million_tokens": { "type": "number" },
"currency": { "type": "string" }
}
}
}
},
"Parameters": {
"type": "object",
"additionalProperties": true
},
"PaginatedModels": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Model"
}
},
"pagination": {
"$ref": "#/components/schemas/Pagination"
}
}
},
"PaginatedProviders": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Provider"
}
},
"pagination": {
"$ref": "#/components/schemas/Pagination"
}
}
},
"PaginatedOverrides": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Override"
}
},
"pagination": {
"$ref": "#/components/schemas/Pagination"
}
}
},
"Pagination": {
"type": "object",
"properties": {
"page": { "type": "integer" },
"limit": { "type": "integer" },
"total": { "type": "integer" },
"totalPages": { "type": "integer" },
"hasNext": { "type": "boolean" },
"hasPrev": { "type": "boolean" }
}
},
"ModelsConfig": {
"type": "object",
"properties": {
"version": { "type": "string" },
"models": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Model"
}
}
}
},
"ProvidersConfig": {
"type": "object",
"properties": {
"version": { "type": "string" },
"providers": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Provider"
}
}
}
},
"OverridesConfig": {
"type": "object",
"properties": {
"version": { "type": "string" },
"overrides": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Override"
}
}
}
},
"CatalogStats": {
"type": "object",
"properties": {
"total_models": { "type": "integer" },
"total_providers": { "type": "integer" },
"total_overrides": { "type": "integer" },
"last_updated": { "type": "string" },
"version": { "type": "string" },
"migration_status": {
"type": "string",
"enum": ["completed", "in_progress", "failed"]
}
}
}
}
}
}