OpenCode
Configuration
Save this file, then replace the placeholder key — or paste your key in the header and copy.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"myprovider": {
"npm": "@ai-sdk/openai-compatible",
"name": "DiscreteStack",
"options": {
"baseURL": "https://api.discretestack.com/v1",
"apiKey": "sk-your-api-key"
},
"models": {
"discretestack-stable-max": {
"name": "discretestack-stable-max",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"limit": {
"context": 200000,
"output": 8192
}
},
"discretestack-stable": {
"name": "discretestack-stable",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"limit": {
"context": 200000,
"output": 8192
}
},
"discretestack-stable-fast": {
"name": "discretestack-stable-fast",
"modalities": {
"input": ["text", "image"],
"output": ["text"]
},
"limit": {
"context": 200000,
"output": 8192
}
}
}
}
}
}
Replace sk-your-api-key with your DiscreteStack API key before saving.
OpenCode
Debug
Share a session for support. These sessions live only on your machine — we cannot see them unless you send them.
If OpenCode hits a problem, export that conversation to a file and send it to DiscreteStack support.
-
Open a terminal (macOS: Terminal or iTerm; Windows: PowerShell or Windows Terminal). You can run these commands from any folder.
-
Show your recent OpenCode conversations:opencode session listYou will see a table with a Session ID (starts with
ses_), a title, and when it was last updated. Find the conversation that had the problem and copy its Session ID.Example output:
ses_0bdc56fd1ffe… Weather in Sofia 5:55 PM -
Export that session to a file on your computer. Replace
ses_XXXXwith the Session ID you copied. Choose one option:# Option A (recommended) — hides sensitive detailsThis creates a file named
opencode export ses_XXXX --sanitize > opencode-session.json
# Option B — full conversation, including your prompts
# Use only if you are comfortable sharing what you typed
opencode export ses_XXXX > opencode-session.jsonopencode-session.jsonin your current folder (the folder shown in the terminal before you ran the command). -
Send
opencode-session.jsonto DiscreteStack support (email, ticket, or whatever channel you use). You can find the file in Finder / File Explorer in the same folder as your terminal.
Cursor
Configuration
Cursor is configured from its Settings UI — no config file to edit. Paste your key in the header to preview it in the mockup.
In the top menu where it says Add or search model, click View All Models → + Add Custom Model and add each one:
Your DiscreteStack models now show up in the model picker — select one and start prompting.
Cursor
Debug
Share a session for support. These sessions live only on your machine — we cannot see them unless you send them.
If Cursor Agent hits a problem, share that conversation file with DiscreteStack support.
-
Open a terminal (macOS: Terminal or iTerm; Windows: PowerShell or Windows Terminal).
-
Go to Cursor’s projects folder:cd ~/.cursor/projectsThen list the folders:lsEach folder is a project. Names encode the full path to your project (for example
/Users/you/AI/my-appbecomes something likeUsers-you-AI-my-app). Pick the folder that matches the project where the problem happened. -
List the Agent conversations for that project:ls <project>/agent-transcriptsReplace
<project>with the folder name from the previous step. Each folder name is a conversation ID (a long UUID). Open the one from when the problem happened, then find the.jsonlfile inside:ls <project>/agent-transcripts/<session-id>
Full path looks like:
<project>/agent-transcripts/<session-id>/<session-id>.jsonl -
Send that
.jsonlfile to DiscreteStack support (email, ticket, or whatever channel you use). You can open the folder in Finder / File Explorer and attach the file from there:open ~/.cursor/projects/<project>/agent-transcriptsTip: before sending, open the file and remove any API keys or secrets if you see them.
Claude Code
Configuration
For a standalone DiscreteStack API key. If you log in with an Anthropic subscription, use claude-ds instead — do not edit settings.json.
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "sk-your-api-key",
"ANTHROPIC_BASE_URL": "https://api.discretestack.com",
"API_TIMEOUT_MS": "3000000",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "discretestack-stable-max",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "discretestack-stable",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "discretestack-stable-fast",
"CLAUDE_CODE_MAX_OUTPUT_TOKENS": "8192",
"MAX_THINKING_TOKENS": "8191"
},
"skipWebFetchPreflight": true
}
Replace sk-your-api-key with your DiscreteStack API key before saving.
After a fresh install, edit ~/.claude.json and set hasCompletedOnboarding to true:
{
"numStartups": 1,
"installMethod": "native",
"autoUpdates": false,
"tipsHistory": {
"new-user-warmup": 1
},
"hasCompletedOnboarding": true,
"projects": {}
}
Important
Only change hasCompletedOnboarding from false to true. This skips the initial setup wizard.
Claude Code
External model (BYOK)
Use discretestack-stable-external to route Claude Code requests through DiscreteStack to your own provider (Anthropic, OpenRouter, etc.). DiscreteStack authenticates your API key; your provider credentials travel in custom headers and are never stored.
Not a full config. Merge the two entries below into the existing env section of ~/.claude/settings.json — alongside Configuration.
Only ANTHROPIC_CUSTOM_HEADERS changes per provider. Provider keys are not filled from the header field.
{
"env": {
// Copy these two entries into your existing env section
"ANTHROPIC_CUSTOM_HEADERS": "x-provider-url: https://api.anthropic.com \n x-provider-api-key: sk-ant-your-provider-key \n x-provider-model: claude-opus-4-7",
"ANTHROPIC_CUSTOM_MODEL_OPTION": "discretestack-stable-external"
}
}
Replace placeholders
x-provider-api-key — your real provider API key in the custom headers (see table below)
x-provider-model — the actual model you want to use
After saving the config, switch to the external model in Claude Code with the /models command and select discretestack-stable-external:
ANTHROPIC_CUSTOM_MODEL_OPTION registers discretestack-stable-external in this list. BYOK routing only applies while that model is selected.
Provider presets for ANTHROPIC_CUSTOM_HEADERS (three \n -separated lines):
| Header | Anthropic | OpenRouter |
|---|---|---|
x-provider-url |
https://api.anthropic.com |
https://openrouter.ai/api |
x-provider-api-key |
sk-ant-... |
sk-or-... |
x-provider-model |
claude-opus-4-7 |
anthropic/claude-opus-4 |
Important
Requests still go to https://api.discretestack.com — not directly to your provider. DiscreteStack authenticates your key, substitutes provider auth, and forwards the request unchanged.
Claude Code
Anthropic subscription users
If you use Claude Code via an Anthropic subscription (Claude Pro / Team / Enterprise) rather than a standalone API key, editing ~/.claude/settings.json would break your subscription login. The claude-ds alias solves this — it's a wrapper script that injects DiscreteStack env vars for that session only, so your main config stays untouched.
These wrapper scripts are for Anthropic subscription users only. If you use a standalone API key, use the Configuration file instead.
~/.claude/settings.json unchanged
env vars override, no settings.json change
Step 1 — Create the wrapper script:
#!/usr/bin/env bash export ANTHROPIC_BASE_URL="https://api.discretestack.com" export ANTHROPIC_AUTH_TOKEN="sk-your-ds-api-key" export ANTHROPIC_DEFAULT_OPUS_MODEL="discretestack-stable-max" export ANTHROPIC_DEFAULT_SONNET_MODEL="discretestack-stable" export ANTHROPIC_DEFAULT_HAIKU_MODEL="discretestack-stable-fast" export CLAUDE_CODE_MAX_OUTPUT_TOKENS=8192 export MAX_THINKING_TOKENS=8191 export API_TIMEOUT_MS="3000000" claude "$@"
Replace sk-your-ds-api-key with your DiscreteStack API key.
Step 2 — Make it executable and add the alias to your shell config:
# Make the script executable chmod +x ~/.claude/claude-ds.sh # Add to ~/.zshrc (or ~/.bashrc) echo 'alias claude-ds="~/.claude/claude-ds.sh"' >> ~/.zshrc source ~/.zshrc
Important
Do not put DiscreteStack settings in ~/.claude/settings.json — this overrides your subscription credentials. The claude-ds wrapper is the correct approach for subscription users.
Claude Code
DiscreteStack + Anthropic subscription
Want to keep your Anthropic subscription and route requests through DiscreteStack? The claude-ds-sub alias combines both — your Anthropic subscription handles the Claude Code session while the env vars route model requests to Anthropic through DiscreteStack.
Anthropic subscription only — this approach relies on Claude Code's subscription auth flow, which is specific to Anthropic.
settings.json unchanged
stable / max / fast
subscription + BYOK
Step 1 — Create the wrapper script:
#!/usr/bin/env bash export ANTHROPIC_BASE_URL="https://api.discretestack.com" export ANTHROPIC_CUSTOM_MODEL_OPTION="discretestack-stable-external" export ANTHROPIC_CUSTOM_HEADERS="x-provider-url: https://api.anthropic.com x-provider-api-key: sk-your-ds-api-key x-provider-model: claude-opus-4-6" export API_TIMEOUT_MS="3000000" export ANTHROPIC_DEFAULT_OPUS_MODEL="discretestack-stable-max" export ANTHROPIC_DEFAULT_SONNET_MODEL="discretestack-stable" export ANTHROPIC_DEFAULT_HAIKU_MODEL="discretestack-stable-fast" export CLAUDE_CODE_MAX_OUTPUT_TOKENS=8192 export MAX_THINKING_TOKENS=8191 claude "$@"
Replace sk-your-ds-api-key with your DiscreteStack API key.
Step 2 — Make it executable and add the alias:
# Make the script executable chmod +x ~/.claude/claude-ds-sub.sh # Add to ~/.zshrc (or ~/.bashrc) echo 'alias claude-ds-sub="~/.claude/claude-ds-sub.sh"' >> ~/.zshrc source ~/.zshrc
How it works
Your Claude.ai subscription authenticates the Claude Code session. When you select discretestack-stable-external via /models, DiscreteStack reads the custom headers, authenticates your access, and forwards the request to your provider.
When you run /models inside claude-ds-sub, Claude Code shows its standard model names — but the env vars map them to DiscreteStack models behind the scenes:
/models |
Env var | Routed to |
|---|---|---|
| Opus | ANTHROPIC_DEFAULT_OPUS_MODEL |
discretestack-stable-max |
| Sonnet | ANTHROPIC_DEFAULT_SONNET_MODEL |
discretestack-stable |
| Haiku | ANTHROPIC_DEFAULT_HAIKU_MODEL |
discretestack-stable-fast |
| discretestack-stable-external ✓ | ANTHROPIC_CUSTOM_MODEL_OPTION |
Your anthropic subscription |
Select options 1–3 to use DiscreteStack-hosted inference. Select option 4 to route through your external provider via subscription auth. You can switch at any time without restarting.
Claude Code
Debug
Share a session for support. These sessions live only on your machine — we cannot see them unless you send them.
If Claude Code hits a problem, share that conversation file with DiscreteStack support.
-
Open a terminal (macOS: Terminal or iTerm; Windows: PowerShell or Windows Terminal).
-
Go to Claude Code’s projects folder:cd ~/.claude/projectsThen list the folders:lsEach folder is a project. Names look a bit odd — they encode the full path to your project (for example
/Users/you/AI/my-appbecomes something like-Users-you-AI-my-app). Pick the folder that matches the project where the problem happened. -
List the conversation files in that project folder (newest first):ls -lt <project>/*.jsonl | headReplace
<project>with the folder name from the previous step. Each.jsonlfile is one conversation. Choose the one from when the problem happened (usually the newest).Example:
cc35691e-8e5d-409e-8e75-72edc5c29448.jsonl -
Send that
.jsonlfile to DiscreteStack support (email, ticket, or whatever channel you use). You can open the folder in Finder / File Explorer and attach the file from there:open ~/.claude/projects/<project>Tip: before sending, open the file and remove any API keys or secrets if you see them.