This commit is contained in:
2026-07-09 02:52:54 +02:00
parent 818568c609
commit 48bb6c2ec2
95 changed files with 6115 additions and 267 deletions
+94
View File
@@ -63,6 +63,22 @@ four ways to sign requests.
],
sample_response={"ok": True, "redirect": "/admin/media"},
),
endpoint(
id="admin-revoke-award",
method="POST",
path="/admin/awards/{uid}/revoke",
title="Revoke award",
summary=(
"Soft-delete a published award and its linked attachments, then recompute "
"receiver stats. Restorable from admin trash."
),
auth="admin",
destructive=True,
params=[
field("uid", "path", "string", True, "", "Award uid to revoke."),
],
sample_response={"ok": True, "redirect": "/profile/receiver?tab=awards"},
),
endpoint(
id="admin-media-purge",
method="POST",
@@ -171,6 +187,84 @@ four ways to sign requests.
"This is the endpoint the Devii assistant calls as `site_analytics`; see [Devii internals](/docs/devii-internals.html).",
],
),
endpoint(
id="admin-statistics",
method="GET",
path="/admin/statistics/data",
title="Platform statistics",
summary=(
"Tabbed platform statistics with KPI cards, period-over-period deltas, "
"time-series data for charts, and breakdown tables. Covers visitors, members, "
"content, engagement, social, AI, Devii, services, containers, game, awards, "
"moderation, tools, and storage."
),
auth="admin",
interactive=True,
params=[
field(
"tab",
"query",
"string",
False,
"overview",
"Tab key (overview, visitors, members, content, ...).",
),
field(
"hours",
"query",
"int",
False,
"168",
"Lookback window in hours (24, 168, 720, 2160, or 0 for all time).",
),
field(
"compare",
"query",
"int",
False,
"1",
"Include previous-period comparison (1 or 0).",
),
field(
"top_n",
"query",
"int",
False,
"10",
"Rows in breakdown tables (1-50).",
),
],
notes=[
"The HTML dashboard lives at `/admin/statistics`. Visitor metrics require the statistics tracking middleware (hourly aggregation, 90-day retention).",
],
),
endpoint(
id="admin-statistics-page",
method="GET",
path="/admin/statistics",
title="Statistics dashboard",
summary="Admin HTML dashboard for platform statistics with charts and tabs.",
auth="admin",
interactive=False,
params=[
field(
"tab",
"query",
"string",
False,
"overview",
"Initial tab to render.",
),
field(
"hours",
"query",
"int",
False,
"168",
"Initial time window in hours.",
),
],
),
endpoint(
id="admin-ai-usage",
method="GET",
+54 -2
View File
@@ -32,6 +32,11 @@ The gateway additionally serves **text embeddings** at `/openai/v1/embeddings`.
generic model `molodetz~embed`, which the gateway maps to the configured embedding model (OpenRouter's
Qwen3 8B embedding model by default). Usage and cost are tracked per call exactly like chat and vision.
The gateway also serves **image generation** at `/openai/v1/images/generations`. Clients request the
generic model `molodetz-img-small`, which the gateway maps to the configured image model (OpenRouter's
Flux 1.1 Pro by default). Cost is tracked per call with a flat per-image price when the upstream
returns no native cost.
## Model routing and providers
On top of the single default upstream above, an administrator can register additional named
@@ -60,7 +65,7 @@ and dollar cost directly from the response with no extra request:
| Header | Meaning |
|--------|---------|
| `X-Gateway-Model` | Upstream model actually used for the call |
| `X-Gateway-Backend` | Backend that served it: `chat`, `embed`, or passthrough |
| `X-Gateway-Backend` | Backend that served it: `chat`, `embed`, `image`, or passthrough |
| `X-Gateway-Prompt-Tokens` | Input (prompt) tokens |
| `X-Gateway-Completion-Tokens` | Output (completion) tokens |
| `X-Gateway-Total-Tokens` | Total tokens (prompt + completion) |
@@ -83,7 +88,7 @@ and dollar cost directly from the response with no extra request:
Dollar costs use the upstream's native `cost` field when it returns one
(`X-Gateway-Cost-Native: 1`); otherwise they are computed from the per-million prices of the matched
model route, falling back to the prices configured on the `openai` service when no route matches. The
one denied path that makes no upstream call (embeddings disabled) returns no usage headers.
denied paths that make no upstream call (embeddings or image generation disabled) return no usage headers.
Administrators enable and configure this gateway under [Background Services](/docs/services.html)
(the `openai` service).
@@ -172,6 +177,53 @@ for signing DevPlace's own requests.
"Every response carries the `X-Gateway-*` token and dollar-cost headers (see Per-call cost and usage headers above).",
],
),
endpoint(
id="gateway-images",
method="POST",
path="/openai/v1/images/generations",
title="Image generation",
summary="OpenAI-compatible image generation. Request model molodetz-img-small.",
auth="user",
encoding="json",
params=[
field(
"model",
"json",
"string",
False,
"molodetz-img-small",
"Image model id; the gateway maps molodetz-img-small to the configured model, or to a matching image model route's provider and target model.",
),
field(
"prompt",
"json",
"string",
True,
'"a decorative developer award emblem"',
"Text prompt describing the image to generate.",
),
field(
"size",
"json",
"string",
False,
"512x512",
"Output dimensions (provider-dependent).",
),
field(
"response_format",
"json",
"string",
False,
"b64_json",
"Return format: url or b64_json.",
),
],
notes=[
"Returns `503` when the gateway service is not running or image generation is disabled.",
"Every response carries the `X-Gateway-*` token and dollar-cost headers (see Per-call cost and usage headers above).",
],
),
endpoint(
id="gateway-passthrough",
method="POST",
+67 -2
View File
@@ -32,7 +32,7 @@ four ways to sign requests.
False,
"posts",
"Profile tab.",
["posts", "activity", "followers", "following", "media"],
["posts", "activity", "followers", "following", "media", "awards"],
),
],
),
@@ -60,7 +60,7 @@ four ways to sign requests.
False,
"posts",
"Profile tab.",
["posts", "activity", "followers", "following", "media"],
["posts", "activity", "followers", "following", "media", "awards"],
),
],
),
@@ -254,6 +254,40 @@ four ways to sign requests.
],
sample_response={"api_key": "NEW_UUID"},
),
endpoint(
id="profile-give-award",
method="POST",
path="/profile/{username}/award",
title="Give a member an award",
summary="Create a pending award on another member's profile and enqueue image generation.",
auth="user",
encoding="json",
params=[
field(
"username",
"path",
"string",
True,
"{{ username }}",
"Receiver username.",
),
field(
"description",
"body",
"string",
True,
"Great work on the release!",
"Award message (1-125 characters).",
),
],
sample_response={
"ok": True,
"data": {
"award_uid": "AWARD_UID",
"award_slug": "abc123-great-work",
},
},
),
endpoint(
id="profile-regenerate-avatar",
method="POST",
@@ -650,6 +684,37 @@ four ways to sign requests.
auth="public",
interactive=True,
),
endpoint(
id="award-image",
method="GET",
path="/awards/{slug_or_uid}/{size}",
title="Award image redirect",
summary="Redirect to the stored PNG attachment for a published award.",
auth="public",
params=[
field(
"slug_or_uid",
"path",
"string",
True,
"abc123-great-work",
"Award slug or bare uid.",
),
field(
"size",
"path",
"enum",
True,
"256",
"Image size.",
["512", "256", "64"],
),
],
notes=[
"> Pending or revoked awards return 404.",
"> Response includes long-lived cache headers.",
],
),
endpoint(
id="avatar",
method="GET",