docs: 清理 OpenAI 时代残留,文档改述 vivid 协议 + 渠道架构
- README/README.en 重写:同构网关 + vivid 四端点 + 渠道同步/调度, 明确不支持 OpenAI 协议上游;移除账号池/七大平台/OpenAI 兼容描述 - backend/frontend README、.env.example 更新(补 RUSTFS/COOKIE_SECURE/ CHANNEL_SECRET) - docker-compose 增加 CHANNEL_SECRET(渠道 key AES-GCM 密钥) - 清掉代码注释/文档示例里的 OpenAI/gpt-image-2 残留 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
+18
-4
@@ -1,8 +1,8 @@
|
||||
# Vivid AI backend config template. Copy to .env and fill in real values.
|
||||
# image2api backend config template. Copy to .env and fill in real values.
|
||||
# Real environment variables override .env.
|
||||
|
||||
APP_ENV=development
|
||||
APP_TITLE=Vivid AI
|
||||
APP_TITLE=image2api
|
||||
HTTP_ADDR=:6666
|
||||
|
||||
# PostgreSQL (database must already exist; tables auto-migrate on boot)
|
||||
@@ -13,8 +13,22 @@ REDIS_ADDR=127.0.0.1:6379
|
||||
REDIS_PASSWORD=
|
||||
REDIS_DB=0
|
||||
|
||||
# RustFS / S3-compatible object storage (generated media + reference uploads)
|
||||
RUSTFS_ENDPOINT=http://127.0.0.1:9000
|
||||
RUSTFS_BUCKET=vivid-ai
|
||||
RUSTFS_ACCESS_KEY=YOUR_AK
|
||||
RUSTFS_SECRET_KEY=YOUR_SK
|
||||
|
||||
# Channel upstream API keys are stored AES-GCM encrypted with this secret.
|
||||
# Set a random value in production and keep it stable — changing it makes
|
||||
# previously saved channel keys undecryptable.
|
||||
CHANNEL_SECRET=change-me-channel-secret
|
||||
|
||||
# Frontend dev origins allowed for CORS
|
||||
CORS_ORIGINS=http://localhost:5173,http://127.0.0.1:5173
|
||||
|
||||
# Optional: override generated media root (defaults to ../../ai-gateway/data/generated)
|
||||
# GENERATED_ROOT=
|
||||
# Set to true when serving the site over HTTPS (session cookie Secure flag)
|
||||
COOKIE_SECURE=false
|
||||
|
||||
# SESSION_COOKIE_NAME=vivid_session
|
||||
# GENERATED_ROOT= # optional: override generated media root
|
||||
|
||||
+19
-47
@@ -1,55 +1,27 @@
|
||||
# Vivid AI Backend
|
||||
# image2api backend
|
||||
|
||||
Go backend for `vivid-ai`, using:
|
||||
Go backend for `image2api` — a vivid-protocol gateway that routes generation
|
||||
jobs across same-protocol upstream channels. Stack: Gin · GORM (PostgreSQL) ·
|
||||
go-redis.
|
||||
|
||||
- Gin
|
||||
- GORM
|
||||
- PostgreSQL
|
||||
- Redis
|
||||
## Architecture sketch
|
||||
|
||||
## 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`
|
||||
- `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
|
||||
|
||||
Set these before running:
|
||||
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.
|
||||
|
||||
```powershell
|
||||
$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"
|
||||
```bash
|
||||
cp .env.example .env # fill in values
|
||||
go build -o bin/api ./cmd/api && ./bin/api
|
||||
```
|
||||
|
||||
Optional:
|
||||
|
||||
```powershell
|
||||
$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
|
||||
|
||||
```powershell
|
||||
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.
|
||||
|
||||
@@ -184,7 +184,7 @@ type DashboardWindow struct {
|
||||
Pending int64 `json:"pending"`
|
||||
Image int64 `json:"image"`
|
||||
Video int64 `json:"video"`
|
||||
API int64 `json:"api"` // source = 'v1' (OpenAI-compatible key)
|
||||
API int64 `json:"api"` // source = 'v1' (vk_ external API key)
|
||||
Web int64 `json:"web"` // everything else (web / playground)
|
||||
Spent float64 `json:"spent"`
|
||||
}
|
||||
|
||||
@@ -653,8 +653,8 @@ func boolValueWithDefault(v any, fallback bool) bool {
|
||||
|
||||
// resolutionsFromPrices mirrors Python models_store._resolutions_from_prices:
|
||||
// an image model's quality tiers ARE its price keys (the admin form never sends
|
||||
// `resolutions` for images), returned in canonical 1K/2K/4K order. gpt-image-2,
|
||||
// for example, only ever has a "1K" price, so it resolves to exactly ["1K"].
|
||||
// `resolutions` for images), returned in canonical 1K/2K/4K order. A model that
|
||||
// only ever has a "1K" price, for example, resolves to exactly ["1K"].
|
||||
func resolutionsFromPrices(prices datatypes.JSONMap) datatypes.JSON {
|
||||
out := []string{}
|
||||
for _, r := range []string{"1K", "2K", "4K"} {
|
||||
|
||||
Reference in New Issue
Block a user