diff --git a/internal/web/static/base.css b/internal/web/static/base.css index 1fb1b69..a692258 100644 --- a/internal/web/static/base.css +++ b/internal/web/static/base.css @@ -170,3 +170,95 @@ select { font: inherit; padding: .35rem .4rem; border: 1px solid var(--line); * design width so scaling up never inflates the 12px labels. */ .ranked { margin: .25rem 0 1rem; } .ranked svg { display: block; width: 100%; max-width: 720px; height: auto; } + +/* The landing page. + * + * It is the only page here a stranger sees, and for most readers it is the whole + * product until they have a key. Everything below is layout and surface: the + * page still says exactly what it said before, and still names no model, no node + * and no count. */ +.banner { border-radius: 6px; padding: .7rem .9rem; margin: 0 0 1.5rem; + border: 1px solid var(--line); background: var(--card); font-size: .875rem; } +.warn-banner { border-color: var(--warn); color: var(--warn); } + +.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); + gap: 2rem; align-items: center; border-bottom: 1px solid var(--line); + margin-bottom: 2.25rem; padding-bottom: 2rem; } +.hero h1 { font-size: 2.6rem; line-height: 1; margin: 0 0 .5rem; letter-spacing: -.03em; } +.hero .sub { font-size: 1.15rem; color: var(--fg); font-weight: 500; } +.hero .lede { color: var(--muted); max-width: 34rem; margin: .75rem 0 0; } +.cta { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1.35rem 0 0; } +.btn { display: inline-block; font-size: .9rem; font-weight: 600; text-decoration: none; + background: var(--accent); color: var(--bg); border: 1px solid var(--accent); + border-radius: 6px; padding: .5rem 1.1rem; } +.btn:hover { filter: brightness(1.1); } +.btn.ghost { background: none; color: var(--accent); border-color: var(--line); } +.btn.ghost:hover { border-color: var(--accent); filter: none; } + +.schematic { margin: 0; } +.schematic svg { display: block; width: 100%; height: auto; } +.schematic figcaption { color: var(--muted); font-size: .8rem; margin-top: .6rem; } +@media (max-width: 760px) { + .hero { grid-template-columns: 1fr; gap: 1.5rem; } + .hero h1 { font-size: 2rem; } +} + +/* The base URL is what a reader came for, so it is a headline rather than a + * line of prose with a colon in it. */ +.url-card { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem 1rem; + background: var(--card); border: 1px solid var(--line); + border-left: 3px solid var(--accent); border-radius: 6px; + padding: .85rem 1.1rem; } +.url-card .k { font-size: .72rem; font-weight: 600; text-transform: uppercase; + letter-spacing: .06em; color: var(--muted); } +.url-card code { font-size: 1.05rem; word-break: break-all; } + +.steps { list-style: none; padding: 0; margin: .5rem 0 0; + display: grid; gap: 1rem; grid-template-columns: repeat(3, minmax(0, 1fr)); } +.steps > li { margin: 0; background: var(--card); border: 1px solid var(--line); + border-radius: 8px; padding: 1.1rem 1.1rem 1.25rem; } +.steps .n { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; + border-radius: 50%; background: var(--accent); color: var(--bg); + font-size: .8rem; font-weight: 700; } +.steps h3 { font-size: .98rem; margin: .6rem 0 .4rem; } +.steps p { margin: .4rem 0 0; font-size: .9rem; } +/* A card is narrower than a line of shell, and a block that scrolls sideways + * inside a card is one nobody discovers they can scroll. */ +.steps pre { margin: .7rem 0 0; font-size: .78em; + white-space: pre-wrap; overflow-wrap: anywhere; } +@media (max-width: 860px) { .steps { grid-template-columns: 1fr; } } + +/* Tabs with no JavaScript: the radios carry the state, so the panel a reader + * chose survives everything including the script never loading. */ +.tabs { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0 .75rem; } +.tabs > input { position: absolute; width: 1px; height: 1px; opacity: 0; } +.tabs > label { display: inline-block; margin: 0; cursor: pointer; font-size: .85rem; + font-weight: 600; color: var(--muted); padding: .35rem .85rem; + border: 1px solid transparent; border-radius: 999px; } +.tabs > label:hover { color: var(--fg); } +.tabs > input:checked + label { color: var(--fg); background: var(--card); + border-color: var(--line); } +.tabs > input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; } +.tabs > .panels { flex: 1 0 100%; } +.tabs .panel { display: none; margin: 0; } +.tabs > input:nth-of-type(1):checked ~ .panels > .panel:nth-child(1), +.tabs > input:nth-of-type(2):checked ~ .panels > .panel:nth-child(2), +.tabs > input:nth-of-type(3):checked ~ .panels > .panel:nth-child(3) { display: block; } + +/* Copy buttons are injected by script, so they are positioned against the block + * they copy rather than reserving space that stays empty without one. */ +pre { position: relative; } +pre .copy { position: absolute; top: .4rem; right: .4rem; padding: .15rem .5rem; + font-size: .72rem; font-weight: 600; background: var(--bg); + color: var(--muted); border: 1px solid var(--line); border-radius: 4px; + opacity: 0; transition: opacity .12s; } +pre:hover .copy, pre .copy:focus-visible { opacity: 1; } +pre .copy:hover { color: var(--fg); filter: none; } + +.endpoints { list-style: none; padding: 0; margin: .5rem 0 0; } +.endpoints > li { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .8rem; + padding: .55rem 0; border-bottom: 1px solid var(--line); margin: 0; } +.endpoints > li:last-child { border-bottom: none; } +.endpoints > li span { color: var(--muted); font-size: .85rem; } +/* A button revealed by hover is a button a phone never has. */ +@media (hover: none) { pre .copy { opacity: 1; } } diff --git a/internal/web/templates/landing.html b/internal/web/templates/landing.html index 9280c6b..6afb79b 100644 --- a/internal/web/templates/landing.html +++ b/internal/web/templates/landing.html @@ -1,68 +1,214 @@ {{define "landing"}}
-An OpenAI-compatible endpoint in front of self-hosted models.
+ +{{if .Notice}}{{end}} +{{if not .AuthEnabled}} + +{{end}} + +One OpenAI-compatible endpoint in front of your own GPUs.
+Point any OpenAI client at this address. The API is the one you + already have a client for — only the base URL changes.
++ {{if .SignupOpen}}Create an account + Sign in + {{else if .AuthEnabled}}Sign in{{end}} +
+Point any OpenAI client at this address. The API is the one you already have a -client for; only the base URL changes.
+{{.BaseURL}}/v1
+{{.BaseURL}}/v1
+Create an account. Someone approves it, and then you issue + your own keys from your profile — as many as you need, + revoking them yourself when a laptop is retired or a script is done.
+ {{else if .Contact}} +Ask {{if .ContactHref}}{{.Contact}}{{else}}{{.Contact}}{{end}} + for one.{{if .AuthEnabled}} If you already have an account, + sign in.{{end}}
+ {{else}} +Keys are issued by whoever operates this gateway. If you do not know who that + is, the address you reached this page at is the place to start asking.
+ {{end}} +A key is shown once and never again — only its hash is kept here — + so put it in a password manager straight away.
+Set the base URL above and your key. Every OpenAI SDK, and every tool built on + one, takes both as configuration.
+export OPENAI_BASE_URL={{.BaseURL}}/v1
+export OPENAI_API_KEY=$LLMGW_API_KEY
+ GET /v1/models lists what is available to your key. It needs the
+ key, which is why this page does not list them: this page is served to anyone who
+ can reach the address.
GET /v1/models lists what is available.
Sending the placeholder <model-name> unchanged is
+ answered with the list of models you may use, rather than with an error.
curl {{.BaseURL}}/v1/chat/completions \
+Connect your client
+
+
+
+
+
+ curl {{.BaseURL}}/v1/chat/completions \
-H "Authorization: Bearer $LLMGW_API_KEY" \
-H "Content-Type: application/json" \
- -d '{"model": "<model-name>", "messages": [{"role":"user","content":"hello"}]}'
-
- Replace <model-name> with a name from
- GET {{.BaseURL}}/v1/models, which needs your key. Sending the
- placeholder unchanged is answered with the list of models that are available.
-
+ -d '{"model": "<model-name>",
+ "messages": [{"role": "user", "content": "hello"}]}'
-from openai import OpenAI
-client = OpenAI(base_url="{{.BaseURL}}/v1", api_key=os.environ["LLMGW_API_KEY"])
+ import os
+from openai import OpenAI
-Which models
-{{if .AuthEnabled}}
-GET /v1/models lists what is available to your key. It needs the key,
-which is why this page does not list them: this page is served to anyone who can
-reach the address.
-{{else}}
-GET /v1/models lists what is available.
-This gateway has no API keys configured, so it serves anyone who can
-reach it. That is a deployment choice and only safe on a trusted network.
-{{end}}
+client = OpenAI(base_url="{{.BaseURL}}/v1",
+ api_key=os.environ["LLMGW_API_KEY"])
-Getting a key
-{{if .SignupOpen}}
-Create an account. Someone will approve it, and then you
-can issue your own keys from your profile — as many as you
-need, revoking them yourself when a laptop is retired or a script is done.
-Already have an account? Sign in.
-{{else if .Contact}}
-Ask {{if .ContactHref}}{{.Contact}}{{else}}{{.Contact}}{{end}}
-for one. {{if .AuthEnabled}}If you already have an account,
-sign in.{{end}}
-{{else}}
-Keys are issued by whoever operates this gateway. If you do not know who that
-is, the address you reached this page at is the place to start asking.
-{{end}}
-A key is shown once and never again — only its hash is kept here — so put it in
-a password manager straight away.
+reply = client.chat.completions.create(
+ model="<model-name>",
+ messages=[{"role": "user", "content": "hello"}],
+)
+print(reply.choices[0].message.content)
-{{if .Notice}}{{.Notice}}
{{end}}
+ // ~/.config/opencode/opencode.json
+{
+ "$schema": "https://opencode.ai/config.json",
+ "provider": {
+ "llmgw": {
+ "npm": "@ai-sdk/openai-compatible",
+ "name": "llmgw",
+ "options": {
+ "baseURL": "{{.BaseURL}}/v1",
+ "apiKey": "{env:LLMGW_API_KEY}"
+ },
+ "models": { "<model-name>": { "name": "<model-name>" } }
+ }
+ }
+}
+
+
+Anything that speaks the chat-completions API works, whether or not it
+is listed here — there is nothing llmgw-specific to install.
-Once you have one
-GET {{.BaseURL}}/v1/models — what your key may useGET {{.BaseURL}}/me — its limits, and what it has spentGET {{.BaseURL}}/v1/modelswhat your key may useGET {{.BaseURL}}/meits limits, and what it has spent