Set up or reconfigure inference backends and API keys. Use when user gets InferenceSetupRequiredError, wants to set up inference for the first time, says "set up pipelex", "configure backends", "configure inference", "set up API keys", "pipelex setup", "pipelex init", or gets a config/credential error when running. Guides through Pipelex Gateway (recommended) or Bring Your Own Key setup.
You've built a method — now let's run it. Before your first live inference run, you need to configure how Pipelex connects to AI models. This is a one-time setup.
Run this command to check toolchain status:
~/.claude/plugins/marketplaces/mthds-plugins/bin/mthds-env-check "0.4.1" 2>/dev/null || ../mthds-plugins/bin/mthds-env-check "0.4.1" 2>/dev/null || echo "MTHDS_ENV_CHECK_MISSING"
Interpret the output:
MTHDS_AGENT_MISSING → STOP. Do not proceed. Tell the user:The
mthds-agentCLI is required but not installed. Install it with:
npm install -g mthds
Then re-run this skill.
MTHDS_AGENT_VERSION_UNKNOWN → STOP. The installed mthds-agent returned an unparseable version. Tell the user:Could not parse the output of
mthds-agent --version. Your installation may be corrupt. Reinstall with:npm install -g mthds@latestThen re-run this skill.
MTHDS_AGENT_OUTDATED <installed> <required> → The installed mthds-agent is too old for this plugin. Do not hard-stop. Instead, tell the user their mthds-agent (v<installed>) is older than the required v<required>, then follow the upgrade flow to offer upgrading mthds-agent via npm install -g mthds@latest. After the upgrade flow completes (whether the user upgraded or declined), proceed to Step 1. The upgrade flow's "Not now" and "Never ask" options let users continue with current versions.
MTHDS_UPDATE_CHECK_FAILED ... → WARN. The update check command failed. Show the error output to the user. Suggest checking network connectivity and mthds-agent installation. Proceed to Step 1 with current versions.
UPGRADE_AVAILABLE ... → Read upgrade flow and follow the upgrade prompts before continuing to Step 1.
JUST_UPGRADED ... → Announce what was upgraded to the user, then continue to Step 1.
MTHDS_ENV_CHECK_MISSING → WARN. The env-check script was not found at either expected path. Tell the user the environment check could not run, but proceed to Step 1.
No output or UP_TO_DATE → Proceed to Step 1.
Any other output → WARN. The preamble produced unexpected output. Show it to the user verbatim. Proceed to Step 1 cautiously.
Use AskUserQuestion to present the inference setup choice:
Wait for the user's choice before proceeding.
Tell the user about the terms, then use AskUserQuestion to get their decision:
To use the Pipelex Gateway, you need to accept the Terms of Service and Privacy Policy. Review the terms here: https://www.pipelex.com/privacy-policy
By using Pipelex Gateway, anonymous telemetry is enabled to monitor service quality. We only collect technical data (model names, token counts, latency) — never your prompts, completions, or business data.
Question: "Do you accept the Pipelex Gateway Terms of Service and Privacy Policy?"
Header: "Terms"
Options:
If they accept: proceed to the next step.
If they decline: switch to Step 2B (BYOK) instead.
Run:
mthds-agent accept-gateway-terms
This records the acceptance and marks inference setup as complete.
Tell the user:
Now you need a Pipelex Gateway API key. Run this command in the prompt below:
! mthds loginThis will open your browser to create an account (or log in) and automatically save the API key.
Wait for the user to confirm login is complete.
Run:
mthds-agent init -g --config '{"backends": ["pipelex_gateway"]}'
Note: accept_gateway_terms is not needed here — it was already recorded by accept-gateway-terms in the previous step.
Run:
mthds-agent doctor
If healthy, proceed to Step 3. If the API key is missing, remind the user to run ! mthds login again.
Tell the user to set up their API keys. Common providers:
OPENAI_API_KEY=sk-... to ~/.pipelex/.envANTHROPIC_API_KEY=sk-ant-... to ~/.pipelex/.envThey can also export them in their shell profile (~/.zshrc, ~/.bashrc).
Ask which backends to enable.
# Single backend example:
mthds-agent init -g --config '{"backends": ["openai"]}'
# Multiple backends example:
mthds-agent init -g --config '{"backends": ["openai", "anthropic"], "primary_backend": "anthropic"}'
When pipelex_gateway is not among the backends, accept_gateway_terms is not needed.
When 2+ backends are selected without pipelex_gateway, primary_backend is required.
Guide the user to add their API keys to ~/.pipelex/.env:
OPENAI_API_KEY=sk-...ANTHROPIC_API_KEY=sk-ant-...If the user prefers an interactive setup, tell them to run pipelex init inference in their own terminal (not through Claude Code).
Run mthds-agent doctor to confirm keys are valid and configuration is healthy.
Once the doctor reports healthy:
Your inference setup is complete! You can now run your methods with live AI inference.
Then re-run the method that originally triggered this setup (if known), or suggest /mthds-run.