Installing fabriek: LLM credentials
This page is for an agent (or a human) installing or configuring fabriek.
Follow it literally. The engine accepts exactly one credential mechanism per
llm: block and stops at run start, naming the error, when the setup is
wrong: guessing produces a named error, not a working run.
Decide first
- An API key for an OpenAI-compatible endpoint (OpenAI, DeepSeek, and
others) -> use
api_key_env. See API-key endpoint. - A GitHub Copilot subscription -> run
fabriek copilot-loginonce, then useapi_key_secretpointing at the token file. See Copilot subscription. - A Claude Pro or Max subscription -> run
fabriek claude-loginonce, then useapi_key_secretpointing at the token file. See Claude subscription.
Fixed rules:
- The
llm:block carries exactly one ofapi_key_envorapi_key_secret. Neither, or both, is invalid config and the loader rejects it ("set exactly one of 'api_key_env' or 'api_key_secret' on the llm block"). fabriek initscaffolds the API-key shape (DeepSeek plusOPENAI_API_KEY). If the credential is a Copilot or Claude subscription, editfabriek/pipeline.yamlto replace that shape with the matching section below. Do not keep theapi_key_envline and add the other mechanism: that is both, which is rejected.- The workspace must never contain
.env*files. The engine refuses the run when one exists (.env.example,.env.template,.env.sampleare allowed fixtures). - Secrets never appear in
pipeline.yaml. The config names the mechanism; the engine resolves the value host-side and scrubs it from every output it writes.
Get set up
After fabriek init, run fabriek doctor in the repo before the first run.
Every finding prints the exact command or edit that fixes it, so an agent can
run or report it without guessing. fabriek doctor --fix applies the safe,
reversible fixes (today: injecting a missing pip-installed extension) and
prints each command before running it; credential and identity fixes still
print their command for you to run.
Two setup decisions no check can automate:
- Private package feed auth: add the feed to
NuGet.Configwith a personal access token (PAT), then enable single sign-on (SSO) for the organization so the token is authorized for the feed before restore reaches it. - Converting existing
.github/agentsdefinitions into the loop's agents directory: this is a consumer-side sync script that writes to an absoluteagents_dir, not afabriekcommand.
API-key endpoint
llm:
model: openai/deepseek-flash
base_url: https://api.deepseek.com
api_key_env: OPENAI_API_KEY
reasoning_effort: medium
- The engine reads the env var at run start. A missing var fails fast: " environment variable is required".
- Supply the value one of two ways: set it in the host environment, or put
it in a host env file outside the workspace and pass
--env FILE. The engine rejects an--envfile inside the workspace ("secret files must live outside the workspace"). Values already in the host environment win over the file. base_urlmay point at any OpenAI-compatible API.
Copilot subscription
Step 1: run fabriek copilot-login (interactive device flow). It writes
the OAuth token to ~/.fabriek/auth/copilot.json (mode 600).
Step 2: run fabriek copilot-models to list the models this token's tier
can use. Confirm the model name there; do not assume one.
Step 3: point the llm: block at the endpoint with the file-backed secret:
llm:
model: openai/claude-opus-5.5
base_url: https://api.githubcopilot.com
api_key_secret:
from: file
key: ~/.fabriek/auth/copilot.json
json_key: access_token
headers:
Copilot-Integration-Id: vscode-chat
Editor-Version: vscode/1.94.0
Openai-Intent: conversation-panel
The engine reads the token file at run start and uses access_token as the
bearer credential. That is the whole mechanism.
Do not:
- Do not set
OPENAI_API_KEYfor Copilot. Copilot authentication usesapi_key_secret, notapi_key_env. No part of the engine copies the token fromcopilot.jsoninto an environment variable; do not add a copy step. - Do not add
X-GitHub-Api-Version: 2022-11-28toheaders. The endpoint rejects it with 400invalid apiVersion. - Do not drop the
openai/prefix from the model name. A bareclaude-*name routes litellm down the Anthropic wire path and dies at the gateway with a missing-Authorization error.
When the run fails over the credential:
- Token file missing or unreadable at run start -> the run stops and the
error names
fabriek copilot-loginas the fix. - GitHub answers 401 or 403 -> the stored token has the wrong scope (a
token created before the
copilotscope fix). Delete~/.fabriek/auth/copilot.jsonand runfabriek copilot-loginagain. - The token expired -> the run-time file read does not check expiry, so the
endpoint 401s. Run
fabriek copilot-loginagain. - Model unusable ->
gpt-4o-mini(chat context capped at 12288 tokens),claude-opus-4.8, andkimi-k3(the gateway drops tool results) are known-bad on this endpoint. LLM providers lists the current working set.
Claude subscription
Step 1: run fabriek claude-login (opens a browser, PKCE flow). It writes
the token to ~/.fabriek/auth/claude.json.
Step 2: point the llm: block at Anthropic's endpoint:
llm:
model: claude-opus-5-5
base_url: https://api.anthropic.com
api_key_secret:
from: file
key: ~/.fabriek/auth/claude.json
json_key: access_token
- No
headers:block. The engine sends the required auth and API-version headers and the Anthropic billing header automatically. - No
/v1suffix onbase_url. litellm appends the/v1/messagespath. - Bare model names (
claude-opus-5-5, notopenai/claude-opus-5-5). Theopenai/prefix is a Copilot-gateway routing hint; the Claude path wants the native Anthropic route. - Do not set
OPENAI_API_KEYand do not keep anapi_key_envline. - The token expires. Re-run
fabriek claude-loginwhen the run fails over the credential file.