Commit Graph

28 Commits

Author SHA1 Message Date
LovroG05
dc11a8dde5 fix: bill OpenRouter requests using its own reported cost
Cost was always estimated locally from catalog per-token prices, which
drifts from what OpenRouter actually charges (dynamic routing, BYOK,
promos, provider-specific caching). Request OpenRouter's usage.include
extension and use the returned usage.cost as the authoritative figure
when present, falling back to the per-token estimate for providers that
don't report it.
2026-07-01 16:17:05 +02:00
LovroG05
58d9c0a9c0 perf: lazy-load log content, populate user_id, keyset-paginate admin logs
Admin logs list no longer joins prompt/completion content for every row —
content is fetched per-row only when a log is expanded in the dashboard,
since a table of chat-length blobs was slow to serialize even at low row
counts.

request_logs.user_id (previously unpopulated despite an index existing on
it) is now set from the owning key on every insert, including synthetic
dashboard keys, and log queries filter on it directly instead of a
virtual_keys subquery. Pagination switches from OFFSET to a (created_at, id)
keyset cursor so paging deep into the log stays cheap. Adds indexes on
provider_name/key_prefix used by the admin filters.
2026-07-01 16:16:49 +02:00
LovroG05
904c7fcea6 claude is useless now 2026-06-30 23:05:21 +02:00
LovroG05
b0b64f9f24 feat: Dockerfiles and compose deploy setup 2026-06-30 12:31:17 +02:00
LovroG05
8d8bd22ae1 feat: set app icons, PWA manifest, and favicons 2026-06-29 13:36:53 +02:00
LovroG05
a267cc28a5 feat: collapsible think block in chat, separate reasoning from content 2026-06-29 13:18:02 +02:00
LovroG05
057903f350 fix: log dashboard chat requests; add view-logs button on keys page 2026-06-29 13:11:17 +02:00
LovroG05
3fcc933999 feat: show token usage and TPS stats below each assistant message 2026-06-29 13:08:47 +02:00
LovroG05
f977c484b0 fix: inject synthetic key on /api/models to prevent nil dereference 2026-06-29 12:56:39 +02:00
LovroG05
ea2b24ed62 fix: test chat uses OIDC auth via /api/chat + /api/models, no key needed 2026-06-29 12:17:34 +02:00
LovroG05
1f5469bce1 fix: chat page key input + layout height; log reasoning_content in completions 2026-06-29 12:08:41 +02:00
LovroG05
ef3e894484 feat: add Test Chat page with streaming, model picker, stop button 2026-06-29 12:04:44 +02:00
LovroG05
5febc03412 fix: restore General settings (name/log-level/retention), remove OIDC section, wire save 2026-06-29 08:52:11 +02:00
LovroG05
02041751e3 fix: remove dead General settings section, show read-only OIDC config 2026-06-29 08:42:49 +02:00
LovroG05
e56d97f808 fix: enforce key ownership on revoke for non-admin users (IDOR) 2026-06-29 08:38:55 +02:00
LovroG05
21d74ebfe0 feat: OIDC-only auth, user-scoped keys/logs, admin group, 1yr log retention 2026-06-29 08:32:09 +02:00
LovroG05
d7bd1cced0 feat: content logging and per-key analytics
- Migration 000003: request_log_content table (messages jsonb, completion text)
- InsertRequestLog now returns the new row's ID so content can be linked
- Chat handler captures prompt messages and completion text (streaming accumulates deltas)
- ListRequestLogs left-joins content; logs API passes key filter through
- KeyStats query aggregates requests/tokens/cost/errors per key prefix
- GET /api/admin/stats/keys endpoint
- Logs page: expandable rows show prompt + completion inline
- Analytics page: per-key usage table below the chart
2026-06-29 00:01:25 +02:00
LovroG05
43963b255e fix: add json tags to AdminModelRow (was serializing as PascalCase) 2026-06-28 23:49:59 +02:00
LovroG05
9d807a6cf1 feat: OIDC server-side login flow with confidential client
Add /auth/login and /auth/callback handlers. The backend holds the
client secret and exchanges the authorization code server-side;
the browser never sees the secret. Redirect URI and post-login
fragment destination are derived solely from GATEWAY_SERVER_PUBLIC_URL
(required when OIDC is set) to prevent host-header injection.
2026-06-28 23:46:30 +02:00
LovroG05
13e8849047 docs: update README 2026-06-28 23:15:33 +02:00
LovroG05
6227a49992 feat: add React admin dashboard
Tailwind v4 dark design (DM Sans/Mono, violet accent). Pages: Overview,
Logs, API Keys, Providers, Models, Analytics, Routing, Settings.
Auth gate uses localStorage token validated against /api/admin/providers.
Vite builds to internal/web/dist which is embedded into the binary.
2026-06-28 23:15:28 +02:00
LovroG05
4d78d5773d feat: wire server entrypoint; add go-oidc/v3 and uuid dependencies
main.go connects all packages: config → pool → migrate → cipher → store
→ providermgr → catalog → optional OIDC → rate limiter → API server.
WriteTimeout is zero to support SSE streaming; no middleware.Timeout.
Config validation now allows OIDC to be optional (static-token fallback).
2026-06-28 23:15:15 +02:00
LovroG05
457d354d36 feat: add HTTP API layer
chi v5 router with virtual-key auth middleware, admin-auth middleware
(OIDC-first with static-token fallback), chat and embeddings proxy
handlers with RPM/TPM rate limiting, admin CRUD endpoints for
providers/keys/models/settings, request log handler, and embedded
SPA handler.
2026-06-28 23:15:06 +02:00
LovroG05
da47afce5b feat: add core backend packages
store: pgx query layer for all entities
config: viper-based config with OIDC/rate-limit fields
crypto: AES-256-GCM credential encryption
billing: async cost recording post-response
catalog: in-memory model catalog with DB-backed sync
ratelimit: fixed 1-min RPM/TPM window limiter
oidcauth: OIDC JWT admin verification via go-oidc/v3
providermgr: provider lifecycle and credential decryption
providers: OpenAI-compat transport, Anthropic translation, embeddings
2026-06-28 23:14:54 +02:00
LovroG05
1d3a419777 feat: revise core DB schema for provider catalog, settings, and rate limits 2026-06-28 23:14:44 +02:00
LovroG05
2fa715d108 setup 2026-06-27 22:47:37 +02:00
LovroG05
7d72606bb9 frontend 2026-06-27 17:13:07 +02:00
LovroG05
7e7ab5a7e2 init 2026-06-27 16:46:12 +02:00