Coach: Doku fuer die API-Key-Provider und das Handy, und die Image-Pruefungen in der GitLab-CI

AI_COACH.md trennt die zwei Provider-Familien (HTTPS mit Key auf dem Default-Image,
Runtime im coach-Image), beschreibt Endpunkt-Regeln, Modell-Liste, Keys pro Provider
samt einmaliger Migration von coach.json und die zwei Wege auf dem Handy. CHANGELOG
unter Unreleased, .env.example/README/Website/SELF_HOSTING nachgezogen.

.gitlab-ci.yml bekommt test:api (Suite, generierte Assets, core-loadable) und
build:api-check, das beide api-Targets baut und laufen laesst: das veroeffentlichte
Image hat kein SDK/codex/bwrap, bootet, und konstruiert die HTTPS-Adapter; das
coach-Image meldet ein lauffaehiges SDK, /coach-auth ist coach 700.
This commit is contained in:
Duarte Santos committed 2026-08-29 17:18:56 +02:00
1 parent 7047346da1
commit 533ca2c9a4
7 files changed
+291 -26

No files matched your search

+12 -8
View File
@@ -127,13 +127,17 @@ RP_NAME=openGym
# VAPID_SUBJECT=mailto:you@example.com
# ── AI Coach (optional, off by default) ────────────────────────────────────
# The Coach is not in the image you get by default, and it stays off even when
# it is: an admin has to turn it on in Settings → Admin and connect a provider
# account. An instance that never does either is byte-for-byte the same app it
# was before the feature existed.
# The Coach stays off until an admin turns it on in Settings → Admin and
# connects a provider. An instance that never does is byte-for-byte the same
# app it was before the feature existed.
#
# API_TARGET picks which API image gets built. `default` carries no AI runtime
# at all — no Agent SDK, no Codex, no bubblewrap. `coach` adds them (~300 MB):
# Anthropic, OpenAI, Gemini and any OpenAI-compatible endpoint (Ollama, LM
# Studio, vLLM, OpenRouter…) are driven over plain HTTPS with an API key and
# need nothing that is not already in the default image. Nothing to set here.
#
# API_TARGET only matters if you want the Claude Agent SDK or the Codex CLI
# running inside the container. `default` carries no AI runtime at all — no
# Agent SDK, no Codex, no bubblewrap. `coach` adds them (~300 MB):
#
# API_TARGET=coach docker compose up -d --build api
#
@@ -143,7 +147,7 @@ RP_NAME=openGym
#
# COACH_DISABLED=1
#
# Credentials never live here. They are encrypted into ./coach.json, or for the
# Codex provider cached in ./coach-auth — a sibling of ./data, never inside it,
# Credentials never live here. They are encrypted into ./data/coach.json, one
# per provider, or for the Codex provider cached in ./coach-auth — a sibling of ./data, never inside it,
# so a live sign-in does not ride along in the documented backup archive.
# See docs/AI_COACH.md.
+122 -3
View File
@@ -5,8 +5,9 @@
# gitea.com ones (.gitea/, kept only so the mirror stays buildable).
#
# What it does, in order:
# test — frontend + MCP suites, on every branch, MR and tag
# build — the two container images → registry.gitlab.com/duartesantos8/opengym/{api,web}
# test — frontend, MCP and api (Coach) suites, on every branch, MR and tag
# build — the two container images → registry.gitlab.com/duartesantos8/opengym/{api,web},
# and a run of both api targets that proves what each one does and does not carry
# package — the signed Android APK → job artifact + generic package registry
# deploy — the browser-only demo → GitLab Pages
# release — a GitLab Release with the changelog section and links to APK + images
@@ -106,6 +107,34 @@ test:mcp:
when: never
- when: on_success
test:api:
extends: .node
stage: test
cache:
key:
files:
- api/package-lock.json
paths:
- api/.npm
script:
- cd api
- npm ci --cache .npm --prefer-offline --omit=optional
# The Coach tests run on node:test and drive the in-repo fixture provider plus a local mock
# of the Chat Completions shape, so the whole job works without an AI account or the network.
- npm test
- cd ..
# The api's copy of the exercise catalogue and the prompt module are generated and committed.
# A dataset or prompt change that forgets to regenerate them would otherwise only surface as
# "the Coach can't find that exercise" — or a prompt edit that never reached the model.
- node scripts/build-coach-assets.mjs --check
# api/coach/core is imported by the server under bare node AND by the phone under Vite.
# vitest forgives what node does not (?raw, import.meta.glob); this runs outside vitest.
- node api/scripts/check-core-loadable.mjs
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- when: on_success
# --------------------------------------------------------------------------- images
# Images land at registry.gitlab.com/duartesantos8/opengym/{api,web} and are what
@@ -131,7 +160,7 @@ build:images:
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_TLS_VERIFY: "1"
DOCKER_CERT_PATH: "/certs/client"
needs: ["test:frontend", "test:mcp"]
needs: ["test:frontend", "test:mcp", "test:api"]
parallel:
matrix:
- IMAGE: api
@@ -199,6 +228,96 @@ build:images:
when: manual
allow_failure: true
# Builds *and runs* both api targets. Building alone would not have caught the api image
# shipping without coach/ — that image built perfectly and exited on boot. So each target has to
# answer for itself: the untargeted build (which is what build:images publishes, since it names
# no --target) boots, serves, carries no AI runtime and still constructs the HTTPS providers;
# the coach one additionally resolves the Agent SDK's per-platform runtime (musl on this base),
# which is the one thing that cannot be checked from the source tree. amd64 only, never pushed.
build:api-check:
stage: build
image: docker:28-cli
services:
- docker:28-dind
variables:
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_TLS_VERIFY: "1"
DOCKER_CERT_PATH: "/certs/client"
needs: ["test:api"]
script:
- docker build --target default -t opengym-api:default ./api
- docker build --target coach -t opengym-api:coach ./api
# No --target, exactly like build:images. What it ships is whatever Dockerfile stage happens
# to be last, and that untargeted artifact is the image every self-hoster pulls as :latest.
- docker build -t opengym-api:published ./api
# --- the published image has no AI runtime, and does not need one for the HTTPS providers
- |
set -eu
docker run --rm opengym-api:published node -e \
'import("@anthropic-ai/claude-agent-sdk").then(()=>{console.error("AI runtime present in the published image -- the last Dockerfile stage is no longer the runtime-free one");process.exit(1)},()=>process.exit(0))'
! docker run --rm opengym-api:published codex --version 2>/dev/null
! docker run --rm opengym-api:published bwrap --version 2>/dev/null
docker run --rm opengym-api:published node --input-type=module -e '
const { adapterFor } = await import("./coach/adapters/index.js");
for (const id of ["anthropic", "openai", "gemini", "compatible"]) {
const a = adapterFor(id);
if (!a || a.spawns !== false || typeof a.invoke !== "function") { console.error(id + " is not a usable HTTPS adapter in the published image"); process.exit(1); }
}
const r = await adapterFor("anthropic").check({}, {});
if (!r.ok || !r.needsKey) { console.error("anthropic.check() without a key should report a ready runtime that needs a key: " + JSON.stringify(r)); process.exit(1); }
console.log("HTTPS providers constructible on the published image");
'
# --- the default image boots and serves
- |
set -eu
docker network create api-net
docker run -d --name api-default --network api-net -e DATA_DIR=/data opengym-api:default
for i in $(seq 1 30); do
docker run --rm --network api-net curlimages/curl:8.12.1 -fsS http://api-default:3000/api/config >/dev/null 2>&1 && break
sleep 1
done
docker run --rm --network api-net curlimages/curl:8.12.1 -fsS http://api-default:3000/api/config | tee /dev/stderr | grep -q '"invite_only"'
docker run --rm opengym-api:default node -e \
'import("@anthropic-ai/claude-agent-sdk").then(()=>{console.error("AI runtime present in the default image");process.exit(1)},()=>process.exit(0))'
docker rm -f api-default
docker network rm api-net
# --- the coach image carries a runnable Agent SDK, Codex and its sandbox
- |
set -eu
docker run --rm opengym-api:coach node --input-type=module -e '
const { adapterFor } = await import("./coach/adapters/index.js");
const r = await adapterFor("claude").check();
if (!r.ok) { console.error(r.error); process.exit(1); }
console.log(r.version);
'
docker run --rm opengym-api:coach codex --version
docker run --rm opengym-api:coach bwrap --version
# Owned by the user jobs drop to, and 0700 — a credential cache readable by anything else
# in the container would undo the point of dropping privileges at all.
test "$(docker run --rm opengym-api:coach stat -c '%U %a' /coach-auth)" = "coach 700"
# --- neither Codex nor its sandbox is in the default image; the privilege drop can be performed
- |
set -eu
! docker run --rm opengym-api:default codex --version 2>/dev/null
! docker run --rm opengym-api:default bwrap --version 2>/dev/null
# canDropPrivileges() fails closed for the runtime-backed providers, so a missing `coach`
# user disables every one of their jobs — including the fixture. Cheaper to assert here.
docker run --rm opengym-api:default id coach
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
paths:
- "api/**/*"
- ".gitlab-ci.yml"
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: manual
allow_failure: true
# ------------------------------------------------------------------------------ apk
# The official signed APK. Signing keys live in protected CI variables, so they only
+35
View File
@@ -1,5 +1,40 @@
# Changelog
## Unreleased
### AI Coach
- 🔑 **Four providers that only need an API key.** Anthropic, OpenAI, Google Gemini, and any
OpenAI-compatible endpoint — Ollama, LM Studio, vLLM, OpenRouter, a gateway of your own — can
now drive the Coach. They speak plain HTTPS from the api process, so they need no AI runtime
in the image and no unprivileged user: **they work on the default `api` image.** The `coach`
image is now only for the Claude Agent SDK and the Codex CLI. Setup is a chip and a pasted key
in Settings → Admin → AI Coach; **List models** fills the model picker from what the endpoint
actually serves. A model on your LAN is the compatible endpoint with no key.
- 🗝️ **Keys, models and account bindings are kept per provider.** Switching chips used to clear
the stored credential; now each provider keeps its own, and the chip shows when one is held.
`./data/coach.json` changed shape for this: an existing file's one flat credential, model and
binding are lifted onto the provider they belonged to on first load. **One-way** — downgrading
to an earlier build will not read them back, which costs one paste of the key.
- 🔓 **The Anthropic API-key path was unreachable.** The admin card hid "Use an API key" for
any provider that also took a setup token, which was exactly the Claude one. Both buttons
render now.
- 📱 **The Coach on the App-Store build**, chosen in Settings → AI Coach: pair the phone with
your self-hosted instance and the Coach runs there, or bring your own API key and the phone
calls the provider directly with the same allowlist, validator and repair round as the server.
Nothing AI-related is loaded until one of the two is chosen; a BYOK key lives in the
platform's secure storage, never in the app's state; a local daily cap bounds what you spend.
- 🧱 The Coach's core — payload builder, validator, parser, prompts, plan fingerprint and the
invoke → parse → validate → repair loop — moved to `api/coach/core/`, runtime-neutral, so the
phone imports the same code the server runs. The exercise catalogue and the prompts are
generated ES modules (`scripts/build-coach-assets.mjs --check` in CI), and
`api/scripts/check-core-loadable.mjs` proves the core still loads under bare node.
- 🛡️ Validator hardening: the lifter's own custom exercises are now accepted when the model
names them (they were offered to it and then refused, burning the one repair round); ids that
are object keys downstream (`__proto__`, `constructor`) are refused; weight and speed have
ceilings; an exercise cannot be added twice to a routine; two changes cannot share an id; a
weight for an exercise never lifted is dropped rather than guessed.
## v1.2.11 — 2026-08-25
A correction release. v1.2.10 landed planned warm-ups and notes, and reviewing that release
+5 -4
View File
@@ -88,7 +88,7 @@ as a home-screen app, passkey sign-in, offline support, sync across your phone a
- 📥 **Bring your history with you** — import from **FitNotes** (Android and iOS), **Strong** and **Hevy**, or body weight straight out of an **Apple Health** export. Exercise names are matched against the library and anything unrecognised becomes one of your own exercises, so nothing in the file is dropped
- 📦 **Yours to keep** — one-tap JSON export/import, guest mode, **no telemetry**
- 🤖 **Ask an AI about your training** (optional) — an [MCP server](mcp/README.md) lets a client like Claude Desktop or Cursor read your history in your own words: *"what did I bench last week?"*. Read-only, spawned locally by the client, nothing leaves your box. Not in the Docker build — if you don't use an AI assistant, it isn't there
- 🧠 **An AI coach that writes your plan** (optional, off by default) — answer a handful of questions and it designs a week of routines; later it reads what you actually logged and proposes changes, each one with the evidence behind it. You approve every change and can undo it. It runs on **your** server under **your** provider account, and it needs a separate image to exist at all — the default build carries no AI runtime whatsoever. See [docs/AI_COACH.md](docs/AI_COACH.md)
- 🧠 **An AI coach that writes your plan** (optional, off by default) — answer a handful of questions and it designs a week of routines; later it reads what you actually logged and proposes changes, each one with the evidence behind it. You approve every change and can undo it. It runs on **your** server under **your** provider account — Anthropic, OpenAI, Gemini or any OpenAI-compatible endpoint (Ollama on your LAN counts) with a pasted API key on the default image, or the Claude Agent SDK / Codex CLI on a separate build. The phone app can use your instance or its own key. See [docs/AI_COACH.md](docs/AI_COACH.md)
- 📱 **Standalone Android app** — the whole tracker as a sideloadable APK: no account, no server, data on the phone, native workout reminders ([download](https://opengym.duarte-santos.ch))
## Quick start (self-host)
@@ -184,7 +184,7 @@ All via `.env` (see `.env.example`):
| `AUDIT_DAYS` | Days kept in the activity log; `0` to keep until `AUDIT_MAX` | `90` |
| `AUDIT_IP` | Record the caller's address: `off`, `net` (network only) or `full` | `off` |
| `VAPID_SUBJECT` | Contact URL sent with push notifications | your `ORIGIN` |
| `API_TARGET` | Which API image to build: `default` (no AI runtime) or `coach` | `default` |
| `API_TARGET` | Which API image to build: `default` (no AI runtime — API-key providers still work) or `coach` (adds the Claude Agent SDK + Codex CLI) | `default` |
| `COACH_DISABLED` | Set to `1` to force the AI Coach off instance-wide, whatever the admin toggled | *(unset)* |
Push notification keys are generated on first run and saved to `./data/vapid.json` — nothing to set.
@@ -223,8 +223,9 @@ React, the router and Zustand.
The optional AI Coach (`api/coach/`) is built the same way round: a by-name allowlist decides
what may leave the server, and a closed-list validator decides what may come back — the model
can touch routines and the weekly schedule, nothing else, and every change is applied on the
client only after you approve it. The AI runtime lives in a separate Docker build target, so an
instance that never asks for it never carries it. See [docs/AI_COACH.md](docs/AI_COACH.md).
client only after you approve it. The core of it — `api/coach/core/` — has no Node dependency,
so the phone app runs the same validator the server does. The in-container AI runtimes live in a
separate Docker build target; the API-key providers need none. See [docs/AI_COACH.md](docs/AI_COACH.md).
The same pure helpers power an optional MCP server (`mcp/`) that lets an LLM client like
Claude Desktop read your data over stdio — see [mcp/README.md](mcp/README.md). Opt-in, not
+103 -6
View File
@@ -9,11 +9,68 @@ running on your own server under your own provider account, off until an admin t
---
## Two kinds of provider
The Coach can be driven by two kinds of thing, and which kind you pick decides how much of the
rest of this document applies to you.
| Provider | What runs | Credential | Image |
| --- | --- | --- | --- |
| **Anthropic API** | plain HTTPS to `api.anthropic.com` | an API key | default |
| **OpenAI API** | plain HTTPS to `api.openai.com` | an API key | default |
| **Google Gemini** | plain HTTPS to `generativelanguage.googleapis.com` | an API key | default |
| **OpenAI-compatible endpoint** | plain HTTPS to a URL you give it — Ollama, LM Studio, vLLM, OpenRouter, a gateway of your own | an API key, optional | default |
| **Claude (Anthropic)** | the Claude Agent SDK, inside the container | a `claude setup-token` | `coach` |
| **Codex (OpenAI)** | the Codex CLI, inside the container | Codex's own device sign-in | `coach` |
The first four spawn nothing. A job is one HTTPS request from the api process, so there is no
child process to drop privileges on, no runtime to carry in the image, and nothing to install:
**they work on the image every instance already has.** The `coach` image, the unprivileged
`coach` user and the `./coach-auth` mount described further down exist for the last two only.
A model on your own LAN is the compatible endpoint with no key: point it at
`http://ollama.lan:11434` and pick a model from the list it serves. That is the whole
configuration.
## Turning it on
Nothing here is an environment variable or a restart — the whole point of the admin card is that
enabling the Coach is a decision you make in the app.
### With an API key (Anthropic, OpenAI, Gemini, compatible)
**1. Get a key** from the provider's own console. For a compatible endpoint, get the URL it
answers on instead, and a key only if it wants one.
**2. Connect it.** In the app: **Settings → Admin → AI Coach**.
- Toggle the card on.
- Pick the provider chip.
- For a compatible endpoint, enter the **Endpoint** — `http://` or `https://`, no username or
password in it, no query string. The host is written into the job log so you can see where
jobs went.
- **Use an API key** → paste it. It is encrypted into `./data/coach.json` and is never shown
again.
- **List models** asks the endpoint what it serves and turns the model field into a picker.
Each provider has a starting default (it is in `api/coach/core/providers.js`, and it is a
starting point, not a pin — names go stale, the list does not); the compatible endpoint has
none, because it serves whatever you put behind it.
- **Test the Coach** — a real round trip with no user data anywhere near it.
The card says two things worth reading: which account is being spent, and — for these
providers — that jobs run no child process at all, so the privilege-drop line reads as not
applicable rather than as a problem.
**3. Use it.** Each person opens **Plan → AI Coach**, agrees to the consent screen — which lists
exactly what leaves the server, generated from the same module that builds payloads — and then
either has a plan built from a short intake or asks for a review of what they have logged.
A key, a model and the account binding described below belong to the provider they were
entered for. Switching chips does not clear them: the Anthropic key is still there when you
come back from trying Gemini, and each chip shows a mark when it holds one.
### With a runtime in the container (Claude Agent SDK, Codex CLI)
**1. Build the image that has an AI runtime in it.** The default image deliberately has none:
```bash
@@ -29,7 +86,8 @@ claude setup-token
```
Complete its normal browser sign-in and copy the token it prints. openGym never opens or handles
that flow — it only ever receives the finished token.
that flow — it only ever receives the finished token. (Claude also accepts an Anthropic API key
here, under the same chip; the setup token is the route for a Claude subscription.)
**3. Connect it.** In the app: **Settings → Admin → AI Coach**.
@@ -43,9 +101,7 @@ that flow — it only ever receives the finished token.
The card also states two things worth reading before anyone uses it: whether jobs actually run
unprivileged, and which account is being spent.
**4. Use it.** Each person opens **Plan → AI Coach**, agrees to the consent screen — which lists
exactly what leaves the server, generated from the same module that builds payloads — and then
either has a plan built from a short intake or asks for a review of what they have logged.
**4. Use it** — as above.
> **On a multi-profile instance, read [Whose account pays](#whose-account-pays) first.** In the
> default instance mode the credential binds to the first profile that spends it and **every
@@ -159,7 +215,14 @@ overwriting an edit you made yourself would be the worse failure.
## Isolation
Jobs run as an unprivileged `coach` user that cannot read the files holding secrets, with an
This section is about the two providers that run a runtime inside the container. The HTTPS
providers run nothing: a job is one `fetch` from the api process, the adapter says so
(`spawns: false`), and the gate below asks the adapter rather than assuming — so an instance on
a host with no `coach` user still gets the Coach through an API key, and is only refused the
runtime-backed providers. The admin card reports "this provider runs no child process" in the
place it would otherwise report the drop.
For Claude Agent SDK and Codex jobs run as an unprivileged `coach` user that cannot read the files holding secrets, with an
environment built from nothing rather than filtered from the parent — no `RP_ID`, no
`ADMIN_UIDS`, no VAPID material.
@@ -176,6 +239,10 @@ the owner runs against their own data directory gets `EACCES`.
## You only carry the AI runtime if you ask for it
The HTTPS providers need none, and run on the `default` image below — so as of this release
the `coach` target is only for an owner who specifically wants the Claude Agent SDK or the
Codex CLI. Everything else in this section is about those two.
`api/Dockerfile` builds two targets from one file:
- **`default`** — what every instance has always had. `npm ci --omit=optional` skips the Agent
@@ -224,7 +291,20 @@ cannot reach it by inheritance even by accident.
## Where a credential lives
Two shapes, because the two providers work differently:
Everything a provider owns — its credential, its model, and in instance mode the profile its
credential bound to — is stored **per provider** in `coach.json`, so switching providers never
throws a key away. An instance upgraded from an earlier build, where the file held one flat
credential and one model for whichever provider was selected, has them lifted onto that
provider the first time the new server reads the file. This is one-way: a downgrade will not
read the maps back, and costs one paste of the key.
Three shapes, because the providers work differently:
- **The HTTPS providers** hold an API key, encrypted with the instance secret into
`coach.json`, and hand it to the request as a header — `x-api-key`, `Authorization: Bearer`
or `x-goog-api-key`, never a query parameter, so it stays out of proxy logs and error
messages. It is inside `./data`, so it *is* in the documented backup; without `./data/secret`
the blob is undecryptable, which is the same protection every other credential there has.
- **Claude** takes its credential on the environment, so nothing is written to disk beyond the
encrypted blob in `coach.json` — it reaches the model process as `CLAUDE_CODE_OAUTH_TOKEN` (or
@@ -243,6 +323,23 @@ Per-profile credentials follow the same rule for the same reason: they live in
`coach-auth-<uid>.json` at mode `0600`, never in the synced state blob, so they cannot ride along
in a device sync or in a user's own JSON export.
## On the phone
The App-Store build has no server of its own, so the Coach there is a choice made in
**Settings → AI Coach**, and until it is made nothing AI-related is loaded at all:
- **Use my self-hosted openGym.** Pair the phone with your instance (the same pairing flow as
syncing — **Settings → Pair the mobile app** on the site, then the address and code on the
phone). A paired phone is an ordinary profile: the Coach runs on your server with whatever
provider the admin configured, under the rules above, and nothing on the phone changes.
- **Bring my own API key.** The phone calls Anthropic, OpenAI, Gemini or a compatible endpoint
directly, with a key you paste. It runs the same payload allowlist, the same validator and
the same single repair round as the server, in the app. The key is kept in the platform's
secure storage — Keychain on iOS, the Keystore-backed store on Android — and never in the
app's state, so it cannot ride along in a backup, an export or a sync. You pay: the screen
says which host each request goes to and what leaves the device before you choose, and a
local daily cap stands in for the one an admin would have set.
## Off is really off
`COACH_DISABLED=1` forces the Coach off everywhere regardless of what is stored — the fleet
+4
View File
@@ -198,6 +198,10 @@ end up in every backup you are told to make — an archive like this gets copied
cloud drives, and a refresh token keeps working wherever it lands. Nothing in `./coach-auth`
needs backing up: if you lose it, sign the provider in again.
API keys for the HTTPS providers (Anthropic, OpenAI, Gemini, a compatible endpoint) are the
other way round: they are in `./data/coach.json`, encrypted with `./data/secret`, so they *are*
in this archive — and unreadable without the secret next to them, like everything else in it.
## 7. Notifications
openGym can push two kinds of alert to your phone/desktop, even when the app isn't open:
+10 -5
View File
@@ -144,11 +144,16 @@ docker compose up -d</code></pre>
it. Answer a few questions — goal, days a week, session length, equipment, anything to work
around — and it builds a week of routines. Every suggestion carries the evidence behind it,
you approve or reject each one, and you can undo the last set of changes.</p>
<p>It is <b>off by default and not in the default image</b>. The Coach needs a build that
includes an AI runtime, which the normal one deliberately does not carry:</p>
<p>It is <b>off by default</b>. An admin turns it on in <b>Settings → Admin → AI Coach</b>,
picks a provider and pastes a key: <b>Anthropic</b>, <b>OpenAI</b>, <b>Google Gemini</b>, or
any <b>OpenAI-compatible endpoint</b> — Ollama or LM Studio on your own LAN, vLLM,
OpenRouter. These speak plain HTTPS and need nothing beyond the default image. Only the
Claude Agent SDK and the Codex CLI need the bigger build:</p>
<pre><code>API_TARGET=coach docker compose up -d --build api</code></pre>
<p>Then an admin turns it on in <b>Settings → Admin → AI Coach</b> and connects a provider
account. It runs on <b>your</b> server under <b>your</b> account — there is no openGym
<p>On the phone app, <b>Settings → AI Coach</b> offers two ways in: pair the phone with your
self-hosted instance and the Coach runs there, or bring your own API key and the phone calls
the provider directly, key in the platform's secure storage.</p>
<p>It runs on <b>your</b> server under <b>your</b> account — there is no openGym
service in the middle, and nothing is sent anywhere until you ask it for something. What
leaves the server is a by-name allowlist (your plan, your logged sets, body weight if you
track it) under a pseudonym; your name, sign-in details and other profiles never do. What
@@ -156,7 +161,7 @@ docker compose up -d</code></pre>
after you approve it.</p>
<p>The Coach is not a doctor or a physiotherapist. If something hurts, ask a professional.
Full details, including exactly what is sent and how credentials are stored:
<a href="https://github.com/DuarteSantos8/openGym/blob/main/docs/AI_COACH.md" rel="noopener">docs/AI_COACH.md</a>.</p>
<a href="https://gitlab.com/DuarteSantos8/opengym/-/blob/main/docs/AI_COACH.md" rel="noopener">docs/AI_COACH.md</a>.</p>
<h2 id="import">Import your training history</h2>
<p>Coming from another tracker? <b>Settings → Data → Import from another app</b> reads:</p>