Files
algorithm/sdk/docs/openapi.yaml
2026-02-08 14:42:58 +08:00

798 lines
19 KiB
YAML

openapi: 3.0.0
info:
title: 智能算法展示平台API
description: 智能算法展示平台的RESTful API接口文档
version: 1.0.0
servers:
- url: http://localhost:8000/api/v1
description: 本地开发环境
components:
schemas:
Algorithm:
type: object
properties:
id:
type: string
description: 算法ID
name:
type: string
description: 算法名称
description:
type: string
description: 算法描述
type:
type: string
description: 算法类型
status:
type: string
description: 算法状态
created_at:
type: string
format: date-time
description: 创建时间
updated_at:
type: string
format: date-time
description: 更新时间
versions:
type: array
items:
$ref: '#/components/schemas/AlgorithmVersion'
required:
- id
- name
- description
- type
AlgorithmVersion:
type: object
properties:
id:
type: string
description: 版本ID
algorithm_id:
type: string
description: 算法ID
version:
type: string
description: 版本号
url:
type: string
description: 算法API地址
params:
type: object
description: 算法参数配置
input_schema:
type: object
description: 输入数据格式
output_schema:
type: object
description: 输出数据格式
is_default:
type: boolean
description: 是否为默认版本
created_at:
type: string
format: date-time
description: 创建时间
updated_at:
type: string
format: date-time
description: 更新时间
required:
- id
- algorithm_id
- version
- url
AlgorithmCallRequest:
type: object
properties:
algorithm_id:
type: string
description: 算法ID
version_id:
type: string
description: 版本ID
input_data:
type: object
description: 输入数据
params:
type: object
description: 算法参数
required:
- algorithm_id
- version_id
- input_data
AlgorithmCallResult:
type: object
properties:
id:
type: string
description: 调用ID
user_id:
type: string
description: 用户ID
algorithm_id:
type: string
description: 算法ID
version_id:
type: string
description: 版本ID
input_data:
type: object
description: 输入数据
params:
type: object
description: 算法参数
output_data:
type: object
description: 输出数据
status:
type: string
description: 调用状态
response_time:
type: number
description: 响应时间(秒)
error_message:
type: string
description: 错误信息
created_at:
type: string
format: date-time
description: 创建时间
updated_at:
type: string
format: date-time
description: 更新时间
required:
- id
- status
OpenAIGenerateRequest:
type: object
properties:
prompt:
type: string
description: 描述
data_type:
type: string
description: 数据类型
required:
- prompt
OpenAIGenerateResponse:
type: object
properties:
data:
type: object
description: 生成的数据
type:
type: string
description: 数据类型
User:
type: object
properties:
id:
type: string
description: 用户ID
username:
type: string
description: 用户名
email:
type: string
description: 邮箱
role:
type: string
description: 角色
status:
type: string
description: 状态
created_at:
type: string
format: date-time
description: 创建时间
updated_at:
type: string
format: date-time
description: 更新时间
UserLoginRequest:
type: object
properties:
username:
type: string
description: 用户名
password:
type: string
description: 密码
required:
- username
- password
UserRegisterRequest:
type: object
properties:
username:
type: string
description: 用户名
email:
type: string
description: 邮箱
password:
type: string
description: 密码
required:
- username
- email
- password
TokenResponse:
type: object
properties:
access_token:
type: string
description: 访问令牌
token_type:
type: string
description: 令牌类型
expires_at:
type: string
format: date-time
description: 过期时间
APIKey:
type: object
properties:
id:
type: string
description: API密钥ID
user_id:
type: string
description: 用户ID
key:
type: string
description: API密钥
name:
type: string
description: 密钥名称
expires_at:
type: string
format: date-time
description: 过期时间
status:
type: string
description: 状态
created_at:
type: string
format: date-time
description: 创建时间
updated_at:
type: string
format: date-time
description: 更新时间
APIKeyCreateRequest:
type: object
properties:
name:
type: string
description: 密钥名称
expires_at:
type: string
format: date-time
description: 过期时间
required:
- name
- expires_at
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
paths:
/algorithms:
get:
summary: 获取算法列表
description: 获取所有算法的列表,可选择按类型过滤
parameters:
- in: query
name: type
schema:
type: string
description: 算法类型
responses:
'200':
description: 成功
content:
application/json:
schema:
type: object
properties:
algorithms:
type: array
items:
$ref: '#/components/schemas/Algorithm'
total:
type: integer
post:
summary: 创建算法
description: 创建新的算法
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
name:
type: string
description:
type: string
type:
type: string
required:
- name
- description
- type
responses:
'200':
description: 成功
content:
application/json:
schema:
$ref: '#/components/schemas/Algorithm'
/algorithms/{algorithm_id}:
get:
summary: 获取算法详情
description: 获取指定算法的详细信息
parameters:
- in: path
name: algorithm_id
schema:
type: string
required: true
description: 算法ID
responses:
'200':
description: 成功
content:
application/json:
schema:
$ref: '#/components/schemas/Algorithm'
put:
summary: 更新算法
description: 更新指定算法的信息
security:
- bearerAuth: []
parameters:
- in: path
name: algorithm_id
schema:
type: string
required: true
description: 算法ID
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
name:
type: string
description:
type: string
type:
type: string
status:
type: string
responses:
'200':
description: 成功
content:
application/json:
schema:
$ref: '#/components/schemas/Algorithm'
delete:
summary: 删除算法
description: 删除指定的算法
security:
- bearerAuth: []
parameters:
- in: path
name: algorithm_id
schema:
type: string
required: true
description: 算法ID
responses:
'200':
description: 成功
content:
application/json:
schema:
type: object
properties:
message:
type: string
/algorithms/{algorithm_id}/versions:
get:
summary: 获取算法版本列表
description: 获取指定算法的所有版本
parameters:
- in: path
name: algorithm_id
schema:
type: string
required: true
description: 算法ID
responses:
'200':
description: 成功
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/AlgorithmVersion'
post:
summary: 创建算法版本
description: 为指定算法创建新的版本
security:
- bearerAuth: []
parameters:
- in: path
name: algorithm_id
schema:
type: string
required: true
description: 算法ID
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
version:
type: string
url:
type: string
params:
type: object
input_schema:
type: object
output_schema:
type: object
is_default:
type: boolean
required:
- version
- url
responses:
'200':
description: 成功
content:
application/json:
schema:
$ref: '#/components/schemas/AlgorithmVersion'
/algorithms/{algorithm_id}/versions/{version_id}:
get:
summary: 获取算法版本详情
description: 获取指定算法版本的详细信息
parameters:
- in: path
name: algorithm_id
schema:
type: string
required: true
description: 算法ID
- in: path
name: version_id
schema:
type: string
required: true
description: 版本ID
responses:
'200':
description: 成功
content:
application/json:
schema:
$ref: '#/components/schemas/AlgorithmVersion'
put:
summary: 更新算法版本
description: 更新指定算法版本的信息
security:
- bearerAuth: []
parameters:
- in: path
name: algorithm_id
schema:
type: string
required: true
description: 算法ID
- in: path
name: version_id
schema:
type: string
required: true
description: 版本ID
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
version:
type: string
url:
type: string
params:
type: object
input_schema:
type: object
output_schema:
type: object
is_default:
type: boolean
responses:
'200':
description: 成功
content:
application/json:
schema:
$ref: '#/components/schemas/AlgorithmVersion'
delete:
summary: 删除算法版本
description: 删除指定的算法版本
security:
- bearerAuth: []
parameters:
- in: path
name: algorithm_id
schema:
type: string
required: true
description: 算法ID
- in: path
name: version_id
schema:
type: string
required: true
description: 版本ID
responses:
'200':
description: 成功
content:
application/json:
schema:
type: object
properties:
message:
type: string
/algorithms/call:
post:
summary: 调用算法
description: 调用指定的算法并获取结果
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AlgorithmCallRequest'
responses:
'200':
description: 成功
content:
application/json:
schema:
$ref: '#/components/schemas/AlgorithmCallResult'
/algorithms/calls/{call_id}:
get:
summary: 获取算法调用结果
description: 获取指定算法调用的结果
security:
- bearerAuth: []
parameters:
- in: path
name: call_id
schema:
type: string
required: true
description: 调用ID
responses:
'200':
description: 成功
content:
application/json:
schema:
$ref: '#/components/schemas/AlgorithmCallResult'
/openai/generate-data:
post:
summary: 生成仿真输入数据
description: 使用OpenAI生成仿真输入数据
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/OpenAIGenerateRequest'
responses:
'200':
description: 成功
content:
application/json:
schema:
$ref: '#/components/schemas/OpenAIGenerateResponse'
/openai/describe-image:
post:
summary: 生成图片描述
description: 使用OpenAI生成图片描述
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
image_url:
type: string
required:
- image_url
responses:
'200':
description: 成功
content:
application/json:
schema:
type: object
properties:
description:
type: string
/users/register:
post:
summary: 用户注册
description: 注册新用户
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserRegisterRequest'
responses:
'200':
description: 成功
content:
application/json:
schema:
$ref: '#/components/schemas/User'
/users/login:
post:
summary: 用户登录
description: 用户登录获取令牌
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UserLoginRequest'
responses:
'200':
description: 成功
content:
application/json:
schema:
$ref: '#/components/schemas/TokenResponse'
/users/me:
get:
summary: 获取当前用户信息
description: 获取当前登录用户的信息
security:
- bearerAuth: []
responses:
'200':
description: 成功
content:
application/json:
schema:
$ref: '#/components/schemas/User'
/api-keys:
get:
summary: 获取API密钥列表
description: 获取当前用户的API密钥列表
security:
- bearerAuth: []
responses:
'200':
description: 成功
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/APIKey'
post:
summary: 创建API密钥
description: 为当前用户创建新的API密钥
security:
- bearerAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/APIKeyCreateRequest'
responses:
'200':
description: 成功
content:
application/json:
schema:
$ref: '#/components/schemas/APIKey'
/api-keys/{key_id}:
delete:
summary: 删除API密钥
description: 删除指定的API密钥
security:
- bearerAuth: []
parameters:
- in: path
name: key_id
schema:
type: string
required: true
description: 密钥ID
responses:
'200':
description: 成功
content:
application/json:
schema:
type: object
properties:
message:
type: string
/health:
get:
summary: 健康检查
description: 检查系统健康状态
responses:
'200':
description: 成功
content:
application/json:
schema:
type: object
properties:
status:
type: string