Skip to main content

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:

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.

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".

~/.config/opencode/opencode.json
{
"$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:

OpenCode model picker showing Jarvislabs Token Factory models

Select one and send a prompt:

OpenCode answering a coding prompt with DeepSeek V4.1 Flash on Jarvislabs Token Factory

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".

~/.pi/agent/models.json
{
"$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:

Pi model picker showing Jarvislabs Token Factory models

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

Pi reading a file and answering with DeepSeek V4.1 Flash on Jarvislabs Token Factory

Run the quick setup script above if you also want /thinking level controls and session-affinity headers for prompt caching.

Available models​

Model IDNameContextInputThinking
deepseek-v4.1-flash-1017DeepSeek V4.1 Flash1MText, imageOn/off, low, high, max
glm-5.3-flashGLM-5.3 Flash1MText, image, videoAlways on, low, high, max
qwen-3.8-27b-fp8Qwen 3.8 27B FP8262KText, image, videoOn/off, low, medium, xhigh
gemma-4-31b-itGemma 4 31B IT262KText, image, videoOn/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.