Deploy a model service
Share model providers across Oratorio, bots, and other DotCraft Runtimes. The model service stores API keys and ChatGPT sign-in credentials. Each Runtime connects with its own revocable client credential.
Start the service
From a DotCraft source checkout, copy the Compose template to its deployment directory:
cp -r docker/model-service /opt/dotcraft-models
cd /opt/dotcraft-models
mkdir -p state
cp config.example.json state/config.jsonThe example configures a ChatGPT provider named openai. To use an API key, edit state/config.json:
{
"Providers": {
"openai": {
"Protocol": "openai-responses",
"ApiKey": "$OPENAI_API_KEY"
}
}
}Set the key in this deployment's .env:
OPENAI_API_KEY=your-openai-api-keyThe Compose template passes OPENAI_API_KEY to the model-service container. For other provider environment variables, add matching entries under the service's environment in docker-compose.yml.
For ChatGPT, forward the callback ports from the computer with your browser:
ssh -N -L 1455:127.0.0.1:1455 -L 1457:127.0.0.1:1457 user@model-hostOn the Linux server, run:
docker compose --profile auth run --rm authOpen the printed URL in your browser and complete sign-in. The service keeps the login in state/credentials.
Set MODEL_SERVICE_PUBLISH_HOST in this deployment's .env to the server's private network address. Start the service:
docker compose up -d model-serviceThe default port is 8090. Use HTTPS at your reverse proxy when connecting across an untrusted network.
Connect a Stack
Create a credential for each Runtime. The command prints its client ID and writes the credential to a file:
docker compose run --rm model-service dotcraft model-service --state /state \
client create --name oratorio --provider openai --output /state/oratorio.tokenCopy state/oratorio.token to the machine hosting the Stack, then initialize it:
dotcraft stack init --dir /opt/oratorio-stack --no-start \
--model-service-url http://model-host:8090/model-service/ \
--model-service-token-file /opt/oratorio.token \
--provider openai --model your-model-id
cd /opt/oratorio-stack
docker compose up -d
dotcraft stack doctor --dir /opt/oratorio-stackFor a bot deployment, set the same connection in its .env using a separately created client credential:
DOTCRAFT_MODEL_MODE=remote
DOTCRAFT_MODEL_SERVICE_URL=http://model-host:8090/model-service/
DOTCRAFT_MODEL_SERVICE_TOKEN=your-client-credential
DOTCRAFT_PROVIDER=openai
DOTCRAFT_MODEL=your-model-idKeep each Runtime's workspace and configuration volumes separate from the model service's state directory. Desktop can select models on a connected Runtime. Provider configuration and sign-in are managed on the model service.
Manage access
Revoke a client by its ID:
docker compose run --rm model-service dotcraft model-service --state /state \
client revoke --id your-client-idCheck provider configuration with dotcraft model-service --state /state check. Sign out with dotcraft model-service --state /state auth logout, run through the same Compose service.
Back up the model service's state directory. It contains provider configuration, client grants, and subscription credentials.