m64_174cfd55170a / README.md
43 lines, 1.5 KBraw
openrouter-secrets
A chat endpoint that forwards to a model on OpenRouter, built on hello-world. It shows how a capsule asks for a network host and an API key, and how m64 keeps the key out of the container.
What it shows
[network] needsandwhy: the one host the capsule may reach, and the reason the person reads before granting it.[secrets] required: the key it needs, by name.[[secrets.inject]]: m64's gate addsAuthorization: Bearer <key>to requests foropenrouter.ai, soserver.pynever reads the key. It calls plainhttp://openrouter.aithrough$HTTP_PROXY, and the gate does TLS.
Run it
Store the key once. The value is read from a hidden prompt and never printed:
m64 config secrets set OPENROUTER_API_KEY
m64 config secrets list # names only
Then serve it. The network has to be granted explicitly:
m64 check examples/openrouter-secrets
m64 serve examples/openrouter-secrets --allow-external-network
To keep a capsule's secrets in their own file instead, pass
--secret-file path/to/file.env (lines like OPENROUTER_API_KEY=...).
Without the key, the serve is refused: missing secrets: OPENROUTER_API_KEY.
Without --allow-external-network, it is refused too, naming the flag.
What to look at
m64 net <id>: the capsule's connections, all toopenrouter.ai:443.m64 checkon a copy with a real key pasted intoserver.py: the push is blocked before anything is uploaded./agentexplains the errors: 401 is a key problem, 502 a network problem.