Skip to content

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

  1. An API key for an OpenAI-compatible endpoint (OpenAI, DeepSeek, and others) -> use api_key_env. See API-key endpoint.
  2. A GitHub Copilot subscription -> run fabriek copilot-login once, then use api_key_secret pointing at the token file. See Copilot subscription.
  3. A Claude Pro or Max subscription -> run fabriek claude-login once, then use api_key_secret pointing at the token file. See Claude subscription.

Fixed rules:

  • The llm: block carries exactly one of api_key_env or api_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 init scaffolds the API-key shape (DeepSeek plus OPENAI_API_KEY). If the credential is a Copilot or Claude subscription, edit fabriek/pipeline.yaml to replace that shape with the matching section below. Do not keep the api_key_env line 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.sample are 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.Config with 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/agents definitions into the loop's agents directory: this is a consumer-side sync script that writes to an absolute agents_dir, not a fabriek command.

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 --env file inside the workspace ("secret files must live outside the workspace"). Values already in the host environment win over the file.
  • base_url may 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_KEY for Copilot. Copilot authentication uses api_key_secret, not api_key_env. No part of the engine copies the token from copilot.json into an environment variable; do not add a copy step.
  • Do not add X-GitHub-Api-Version: 2022-11-28 to headers. The endpoint rejects it with 400 invalid apiVersion.
  • Do not drop the openai/ prefix from the model name. A bare claude-* 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-login as the fix.
  • GitHub answers 401 or 403 -> the stored token has the wrong scope (a token created before the copilot scope fix). Delete ~/.fabriek/auth/copilot.json and run fabriek copilot-login again.
  • The token expired -> the run-time file read does not check expiry, so the endpoint 401s. Run fabriek copilot-login again.
  • Model unusable -> gpt-4o-mini (chat context capped at 12288 tokens), claude-opus-4.8, and kimi-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 /v1 suffix on base_url. litellm appends the /v1/messages path.
  • Bare model names (claude-opus-5-5, not openai/claude-opus-5-5). The openai/ prefix is a Copilot-gateway routing hint; the Claude path wants the native Anthropic route.
  • Do not set OPENAI_API_KEY and do not keep an api_key_env line.
  • The token expires. Re-run fabriek claude-login when the run fails over the credential file.