Files
chiyiandDevin b4efe6b192 feat!: 账号池改渠道网关,对外协议换成 vivid /v1
- 新增 channels/channel_models:上游 URL + AES-GCM 加密 key +
  并发/权重/本地统计,模型经渠道 /v1/models 导入绑定
- internal/upstream:vivid 协议客户端(NDJSON 流 + jobId 断流重连 +
  uploads 预签名 + models + balance + 错误分类)
- service/v1 重写:权重分组调度、Redis 并发槽 conc:c:、故障转移,
  站内/测试/对外统一走渠道执行器
- 对外端点换成 vivid 四件套:POST /v1/generate(NDJSON+jobId 重连)、
  POST /v1/uploads(SigV4 预签名 PUT)、GET /v1/models、GET /v1/balance,
  错误包 {"error":{"code","message"}}
- API key 新发改 vk_+48hex;删除全部内置 provider 与 token 池
- 管理端:渠道 CRUD/拉模型/导入/余额端点,前端账号页换渠道页,
  概览/文档/测试弹窗适配

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-10-16 21:14:18 +08:00
..

Vivid AI Backend

Go backend for vivid-ai, using:

  • Gin
  • GORM
  • PostgreSQL
  • Redis

Current scope

This is an in-progress rewrite. The current skeleton already includes:

  • app bootstrap
  • PostgreSQL and Redis initialization
  • GORM auto-migrations
  • session storage in Redis
  • image access control for /images/:user/:name
  • public site endpoint: /admin/api/site
  • public showcase endpoint: /admin/api/showcase
  • session-based auth endpoint: /admin/api/auth/me

Environment

Set these before running:

$env:POSTGRES_DSN="host=127.0.0.1 user=postgres password=postgres dbname=vivid_ai port=5432 sslmode=disable TimeZone=Asia/Shanghai"
$env:REDIS_ADDR="127.0.0.1:6379"
$env:HTTP_ADDR=":6061"

Optional:

$env:APP_ENV="development"
$env:APP_TITLE="Vivid AI"
$env:SESSION_COOKIE_NAME="vivid_session"
$env:CORS_ORIGINS="http://localhost:5173,http://127.0.0.1:5173"

Run

go run ./cmd/api

Notes

  • Generated media defaults to ../../ai-gateway/data/generated relative to the backend working directory.
  • Private images require either:
    • session cookie
    • bearer session token
    • bearer API key
  • Showcase images are public.