feat(server): API relay gateway backend M0-M4

Gin + GORM + pure-Go SQLite. Users/auth (JWT), API key management with
quotas, proxy gateway with weighted channel failover and health checks,
usage/billing ledger, cross-protocol conversion (Anthropic Messages /
OpenAI Chat Completions / OpenAI Responses), and channel/model admin API.
Channels declare native API formats and auto-convert the rest.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Sakurasan
2026-08-15 21:05:02 +08:00
co-authored by Claude Sonnet 5
parent b0c7439c01
commit d0e31b198f
45 changed files with 6222 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
package rand
import (
crand "crypto/rand"
"math/big"
)
const base62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
// Base62 returns a cryptographically random base62 string of length n.
func Base62(n int) (string, error) {
out := make([]byte, n)
for i := range out {
idx, err := crand.Int(crand.Reader, big.NewInt(int64(len(base62))))
if err != nil {
return "", err
}
out[i] = base62[idx.Int64()]
}
return string(out), nil
}