Use Token Factory with OpenCode and Pi
Token Factory serves open-source coding and reasoning models at https://models.jarvislabs.net/v1. You pay per token, with no GPU instance to start or pause.
Before you start
You need a Jarvislabs API key from jarvislabs.ai/settings/api-keys and credit in your wallet at jarvislabs.ai/settings/recharge. If you already installed the Jarvislabs CLI and ran jl setup, you can use that same key.
Install OpenCode, Pi, or both:
- OpenCode
- Pi
curl -fsSL https://opencode.ai/v2/install | bash
Reload your shell with exec $SHELL, then check the install:
opencode --version
You can also install OpenCode with npm install -g @opencode/cli or brew install anomalyco/tap/opencode-v2.
Pi needs Node.js 22.19 or newer. In an interactive terminal, the installer sets up Node.js for you if it is missing:
curl -fsSL https://pi.dev/install.sh | sh
Reload your shell with exec $SHELL, then check the install:
pi --version
On Windows PowerShell, run irm https://pi.dev/install.ps1 | iex. You can also install Pi from npm with npm install -g --ignore-scripts @earendil-works/pi-coding-agent.
Quick setup
Run this command on macOS, Linux, or WSL to configure both OpenCode and Pi. It requires Python 3, and you do not need the Jarvislabs CLI installed.
curl -fsSL https://docs.jarvislabs.ai/scripts/setup-coding-agents.sh | sh
The script checks JL_API_KEY, ~/.config/jarvislabs/api-key, and any Jarvislabs CLI login in that order. If it finds no key, it prints the API keys page link and asks you to paste one with hidden input. Press Enter at an empty prompt to open the page in your browser.
Once the key checks out, the script saves it to ~/.config/jarvislabs/api-key with chmod 600 and fetches the live model list from Token Factory. It then writes ~/.config/opencode/opencode.json and ~/.pi/agent/models.json with per-model thinking controls. If both opencode.json and opencode.jsonc exist, it edits opencode.jsonc. Existing files are backed up to .bak before any change, and only the Jarvislabs provider is updated so your comments and other providers stay intact.
To configure one tool, or inspect the generated JSON before writing files:
# OpenCode only
curl -fsSL https://docs.jarvislabs.ai/scripts/setup-coding-agents.sh | sh -s -- --opencode
# Pi only
curl -fsSL https://docs.jarvislabs.ai/scripts/setup-coding-agents.sh | sh -s -- --pi
# Print the JSON without writing files
curl -fsSL https://docs.jarvislabs.ai/scripts/setup-coding-agents.sh | sh -s -- --print-only
Manual setup
If you want to write the config files yourself, save your key first and then configure OpenCode or Pi below.
1. Save your API key
Put your key in a private file instead of a shell variable. OpenCode runs a background service that can miss shell exports, and a key file works across new terminals without putting secrets in config JSON.
mkdir -p ~/.config/jarvislabs
chmod 700 ~/.config/jarvislabs
printf '%s' 'YOUR_JARVISLABS_API_KEY' > ~/.config/jarvislabs/api-key
chmod 600 ~/.config/jarvislabs/api-key
Replace YOUR_JARVISLABS_API_KEY with your key from jarvislabs.ai/settings/api-keys. Use the quick setup script above if you do not want the key in your shell history.
2. Configure OpenCode
This config is for OpenCode v2 (opencode --version). On v1, use the quick setup script.
Create or edit ~/.config/opencode/opencode.json. If you already use ~/.config/opencode/opencode.jsonc, paste just the "Jarvislabs" block inside "providers".
{
"$schema": "https://opencode.ai/config.json",
"model": "Jarvislabs/deepseek-v4.1-flash-1017",
"providers": {
"Jarvislabs": {
"name": "Jarvislabs Token Factory",
"package": "@opencode/ai/providers/openai-compatible",
"settings": {
"baseURL": "https://models.jarvislabs.net/v1",
"apiKey": "{file:~/.config/jarvislabs/api-key}"
},
"compatibility": {
"reasoningField": "reasoning_content"
},
"models": {
"deepseek-v4.1-flash-1017": {
"name": "DeepSeek V4.1 Flash",
"capabilities": { "tools": true, "input": ["text", "image"], "output": ["text"] },
"limit": { "context": 1048576, "output": 32768 }
},
"glm-5.3-flash": {
"name": "GLM-5.3 Flash",
"capabilities": { "tools": true, "input": ["text", "image"], "output": ["text"] },
"limit": { "context": 1048576, "output": 32768 }
},
"qwen-3.8-27b-fp8": {
"name": "Qwen 3.8 27B FP8",
"capabilities": { "tools": true, "input": ["text", "image"], "output": ["text"] },
"limit": { "context": 262144, "output": 32768 }
},
"gemma-4-31b-it": {
"name": "Gemma 4 31B IT",
"capabilities": { "tools": true, "input": ["text", "image"], "output": ["text"] },
"limit": { "context": 262144, "output": 32768 }
}
}
}
}
}
Keep limit.output at 32768. Token Factory caps replies at 1024 tokens when no limit is sent, and thinking tokens count toward that limit.
Start OpenCode in your project folder. If you have used OpenCode before, run opencode reload first so its background service picks up the new config:
opencode reload
cd /path/to/your/project
opencode
Run /models and type Jarvislabs to pick a model:

Select one and send a prompt:

Thinking is on by default for every Token Factory model. To add per-model effort variants like #low, #high, #max, or #off, run the quick setup script above, then pass a variant such as opencode run -m "Jarvislabs/deepseek-v4.1-flash-1017#low" "Explain app.py".
3. Configure Pi
Create or edit ~/.pi/agent/models.json. If the file already has other providers, paste just the "Jarvislabs" block inside "providers".
{
"$schema": "https://pi.dev/schemas/models.schema.json",
"providers": {
"Jarvislabs": {
"name": "Jarvislabs Token Factory",
"baseUrl": "https://models.jarvislabs.net/v1",
"api": "openai-completions",
"apiKey": "!cat ~/.config/jarvislabs/api-key",
"compat": {
"supportsStore": false,
"supportsDeveloperRole": false,
"supportsReasoningEffort": false,
"maxTokensField": "max_completion_tokens"
},
"models": [
{
"id": "deepseek-v4.1-flash-1017",
"name": "DeepSeek V4.1 Flash",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 1048576,
"maxTokens": 32768
},
{
"id": "glm-5.3-flash",
"name": "GLM-5.3 Flash",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 1048576,
"maxTokens": 32768
},
{
"id": "qwen-3.8-27b-fp8",
"name": "Qwen 3.8 27B FP8",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 262144,
"maxTokens": 32768
},
{
"id": "gemma-4-31b-it",
"name": "Gemma 4 31B IT",
"reasoning": true,
"input": ["text", "image"],
"contextWindow": 262144,
"maxTokens": 32768
}
]
}
}
}
Keep the compat block. Without supportsReasoningEffort: false, Pi sends a reasoning_effort value that DeepSeek and Qwen reject at some thinking levels. On Windows PowerShell, set JL_API_KEY in your environment and change "apiKey" to "$JL_API_KEY".
Start Pi in your project folder:
cd /path/to/your/project
pi
Run /model, type Jarvislabs, and press Enter to select a model or Ctrl+S to make it your default:

Once selected, the model shows in Pi's footer:

Run the quick setup script above if you also want /thinking level controls and session-affinity headers for prompt caching.
Available models
| Model ID | Name | Context | Input | Thinking |
|---|---|---|---|---|
deepseek-v4.1-flash-1017 | DeepSeek V4.1 Flash | 1M | Text, image | On/off, low, high, max |
glm-5.3-flash | GLM-5.3 Flash | 1M | Text, image, video | Always on, low, high, max |
qwen-3.8-27b-fp8 | Qwen 3.8 27B FP8 | 262K | Text, image, video | On/off, low, medium, xhigh |
gemma-4-31b-it | Gemma 4 31B IT | 262K | Text, image, video | On/off |
Models and prices update over time. Check the current list at jarvislabs.ai/products/token-factory, at https://models.jarvislabs.net/v1/public/models, or with jl models list if you use the Jarvislabs CLI. Re-run the quick setup script anytime to pull in new models.