Files
image2api/backend
chiyiandDevin f3b9e570c2 feat(models): 对齐 vivid 新改动——模型删除改软删,重导不丢计数/定价
- model_configs 加 deleted_at(gorm 软删),List/Get 自动过滤,
  GetAny/Unscoped 用于复活与孤儿清理路径
- 渠道同步/删渠道/管理端删除模型的孤儿清理全部走软删
- 导入时若命中软删行:UpdateAny + deleted_at=NULL 复活,
  generation_count 与原定价保留(vivid a42f32c 同语义)
- provider 时代残留仍物理删除(DeleteHard),不留软删垃圾
- OrphanModelIDs 跳过已软删行,避免重复清扫
- btn-primary 禁用态改浅灰填充(vivid d636105)

核对过已等价的:vivid 僵尸任务兜底(我们的 ResumeStaleJob+
PurgeStale+MarkRefunded 同语义)、产物 MIME 魔数嗅探、
retention 按创建时间、渠道同步弹窗(开关+别名)均已覆盖。

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

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

image2api backend

Go backend for image2api — a vivid-protocol gateway that routes generation jobs across same-protocol upstream channels. Stack: Gin · GORM (PostgreSQL) · go-redis.

Architecture sketch

  • internal/upstream — vivid-protocol client (NDJSON generate + jobId resume, /v1/uploads, /v1/models, /v1/balance, error classification)
  • internal/service/channel.go — channel CRUD, upstream model sync (save = full sync), AES-GCM key storage
  • internal/service/v1.go — channel-weighted dispatch, billing, job lifecycle, stale-job resume
  • internal/http/handler/v1.go — public vivid endpoints (/v1/generate /v1/uploads /v1/models /v1/balance)

Environment

See .env.example. Required: POSTGRES_DSN, REDIS_ADDR, RUSTFS_*. Important: CHANNEL_SECRET encrypts stored channel API keys (AES-GCM) — set a random value and keep it stable; rotating it makes saved keys undecryptable.

cp .env.example .env   # fill in values
go build -o bin/api ./cmd/api && ./bin/api