44 Commits

Author SHA1 Message Date
LovroG05
8bb62a1c20 feat: serve a backup model when the requested model fails
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Any model can name another model as its backup. The gateway tries the
backup when the model is offline, rate limited, or its upstream fails
before the client has received anything. The response reports the
requested model, so the client sees no switch. The request log records
each failed attempt and the address that served the request, and the
cost uses the backup's prices.
2026-10-15 09:56:01 +02:00
LovroG05
599b5542c6 fix: write every influx field on every point
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
InfluxDB 3 creates a column on its first write. A dashboard query that
names ttft_ms or error failed until a streamed or failed request had
been exported. Write 0 and empty strings instead of omitting the field.
2026-10-11 17:34:47 +02:00
LovroG05
abecc4b888 feat: export request statistics to InfluxDB 3
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Add an optional exporter that writes one point per proxied request to
the InfluxDB 3 write endpoint. Points are batched in memory and flushed
by size or interval. The exporter is off until GATEWAY_INFLUX_URL is set.
2026-10-11 17:20:14 +02:00
LovroG05
00800d3a3f fix: read the running llama.cpp context and allow a context override
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
The sync took meta.n_ctx_train from the model listing, which is the
training context, not the -c the server runs with. The llama.cpp provider
now asks the server for the live value: /props on a single server, the
router's /models status and /props?model=, and /upstream/<model>/props for
models llama-swap has loaded. Stopped models are never probed, because
that would start them.

Admins can also pin the context window per model from the Models page.
The override wins over the discovered value and survives syncs.
2026-10-04 18:14:09 +02:00
LovroG05
b4426ba359 build: track the web/dist placeholder so a fresh checkout compiles
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
The go:embed pattern needs at least one file under internal/web/dist.
The placeholder was ignored instead of tracked, so CI failed at go vet
before the dashboard build step ran.
2026-10-04 17:52:28 +02:00
LovroG05
75b145a213 build: update dashboard dependencies and add a dev-db target
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
npm audit fix clears four high severity advisories. make dev-db starts
the local Postgres on its own, for the database tests.
2026-10-04 17:32:44 +02:00
LovroG05
4d57318e86 ci: run tests, lint and the UI build on every push
Add a golangci-lint config and fix its findings: the OIDC state cookie
gets the Secure flag on https deployments, and pool sizes are clamped
before the int32 conversion.
2026-10-04 17:32:44 +02:00
LovroG05
aa0821f169 test: cover the proxy handlers and the OpenAI transport
Add a RequestLogSink interface so the handlers can be tested without
Postgres. The tests run the image, chat, stream, embeddings and model
routes end to end against a fake upstream.
2026-10-04 17:32:44 +02:00
LovroG05
4a3c38a1ca fix: charge image fan-out against the RPM limit
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
A request with n images makes n upstream calls. Count all of them in the
rate limiter up front and reject n above 10 before any provider work.
2026-10-04 16:57:52 +02:00
LovroG05
5aadb0f875 feat: serve /v1/images/generations through OpenRouter chat completions
Some checks failed
ci/woodpecker/push/woodpecker Pipeline was canceled
Translate OpenAI image requests to OpenRouter chat completions with image
output and back, as the LiteLLM proxy does. Only models whose provider
reports image output accept the call; the catalog sync now stores the
reported output modalities in the capabilities column.
2026-10-04 16:56:05 +02:00
LovroG05
a845aaa614 feat: full model addresses with copy, searchable picker, connect card
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Model catalog is a table keyed by the exact provider/slug address with
a copy button. The chat model picker filters by address and name.
API Keys shows the base URL and a curl example, also right after a
key is created. /v1/models entries gain created, display_name and
context_length.
2026-10-03 16:34:18 +02:00
LovroG05
4821ddca1a docs: update README for current features, drop unused admin token
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2026-10-03 16:17:11 +02:00
LovroG05
3ec52d82b7 feat: redesign dashboard on shared UI primitives
Shared tokens and components, responsive layout, real health badge,
request volume chart with hover, log detail with errors and cost,
provider enable and edit, override clearing, OIDC re-login that
returns to the current page.
2026-10-03 16:17:11 +02:00
LovroG05
5988e01906 fix: proxy logging, Anthropic translation, and admin API validation
Record upstream and gateway errors in request logs, including stream
interruptions. Translate Anthropic streamed tool calls, count cache
creation tokens, and drop top_p when temperature is set. Coalesce the
stats summary so an empty window no longer returns 500. Validate
provider and setting writes, allow clearing model overrides, add
provider update endpoint, and purge logs at startup.
2026-10-03 16:17:11 +02:00
LovroG05
5c3635b2ea fix: record reasoning from OpenRouter, Anthropic, and dashboard chat
extractDelta and extractCompletion read only reasoning_content, so
reasoning from OpenRouter (reasoning, reasoning_details) and Anthropic
(thinking_delta blocks) was dropped from logged completions. The
streaming path now accumulates reasoning and content separately and
wraps reasoning in think tags, matching the non-streaming format.

The dashboard Test Chat page and the Anthropic stream/translate paths
also recognize the OpenRouter and Anthropic reasoning fields.
2026-08-29 19:07:12 +02:00
LovroG05
72101f92fb chore: migrate to Go 1.27 2026-08-29 18:32:26 +02:00
LovroG05
8d3dee46ba inject created timestamp for OpenAI spec compatibility
OpenWebUI was failing with 'NoneType' errors because it expects a
'created' field on all chat and embedding responses. OpenAI always
includes this unix-timestamp field in both streaming chunks and
non-streaming responses.

- Inject 'created' into non-streaming responses if the upstream
  didn't provide one (chat + embeddings)
- Inject 'created' into every streaming SSE chunk if missing
- Add 'created' to Anthropic synthetic streaming chunks and
  non-streaming translated responses
2026-07-07 11:18:17 +02:00
LovroG05
e02dfd4317 fix tokens 2026-07-01 23:58:45 +02:00
LovroG05
41865c5440 feat: faster 2026-07-01 16:40:17 +02:00
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
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
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