Set Up ASI:One in OpenCode

Overview

ASI:One is OpenAI-compatible, so OpenCode can use it as a custom provider through @ai-sdk/openai-compatible. You declare the provider and its models in opencode.json, then store your key in OpenCode’s credential file.

Prerequisites

  • OpenCode installed and on your PATH.
  • An ASI:One API key. Create one at asi1.ai/developer. Keys start with sk_.
  • An ASI:One plan that includes asi1-ultra. The same key also works for asi1, asi1-ultra-1m and asi1-mini.
  • jq, for the credential step.

Add the provider

Create or edit opencode.json at the root of your project:

{
"$schema": "https://opencode.ai/config.json",
"model": "asi/asi1-ultra",
"provider": {
"asi": {
"npm": "@ai-sdk/openai-compatible",
"name": "ASI:One",
"options": {
"baseURL": "https://api.asi1.ai/v1"
},
"models": {
"asi1": {
"name": "ASI1",
"limit": { "context": 196000, "output": 40000 }
},
"asi1-ultra": {
"name": "ASI1 Ultra",
"limit": { "context": 196000, "output": 40000 }
},
"asi1-ultra-1m": {
"name": "ASI1 Ultra 1M",
"limit": { "context": 1000000, "output": 40000 }
},
"asi1-mini": {
"name": "ASI1 Mini",
"limit": { "context": 196000, "output": 40000 }
}
}
}
}
}

To make ASI:One available in every project, put the same provider block in ~/.config/opencode/opencode.json instead.

OpenCode uses each model’s limit to decide when to compact the conversation. 196,000 fits inside the context window of asi1, asi1-ultra and asi1-mini, and asi1-ultra-1m gets its full 1,000,000. output is the room OpenCode reserves for the reply. Both fields are required whenever a model has a limit block.

Store the API key

OpenCode’s login flow doesn’t list custom providers, so add the key to its credential file directly. This keeps any credentials already in the file and only adds or replaces the asi entry:

printf 'ASI:One API key: '; read -rs ASI_ONE_API_KEY; echo
AUTH_FILE="$HOME/.local/share/opencode/auth.json"
(
umask 077
mkdir -p "$(dirname "$AUTH_FILE")"
[ -f "$AUTH_FILE" ] || printf '{}\n' > "$AUTH_FILE"
jq --arg key "$ASI_ONE_API_KEY" '.asi = { type: "api", key: $key }' \
"$AUTH_FILE" > "$AUTH_FILE.tmp" &&
mv "$AUTH_FILE.tmp" "$AUTH_FILE"
)
chmod 600 "$AUTH_FILE"
unset ASI_ONE_API_KEY

The first line prompts for the key without echoing it, so it never lands in your shell history. umask 077 makes every file the snippet creates readable only by you from the start.

Keep the key in auth.json only. Never put it in opencode.json, which usually lives in your repository.

Verify

opencode providers list
opencode models asi

asi should appear as an api provider, followed by the models:

asi/asi1
asi/asi1-mini
asi/asi1-ultra
asi/asi1-ultra-1m

Then send a request to each model you plan to use:

opencode run -m asi/asi1-mini "Reply with exactly: OK"
opencode run -m asi/asi1-ultra "Reply with exactly: OK"

Each should reply with OK.

Run it

Because the config sets "model": "asi/asi1-ultra", plain opencode starts on asi1-ultra. To pick a model for one session:

opencode -m asi/asi1-mini

Troubleshooting

SymptomCause and fix
Error: failed to authenticate userOpenCode read auth.json while it was missing, invalid or incomplete. Re-run the credential step, then retry.
A model is missing from opencode models asiCheck that opencode.json is at the project root (not .opencode/config.json), that the JSON is valid, and that every limit block has both context and output.
401The key is wrong or has been revoked. Create a new one at asi1.ai/developer and re-run the credential step.
404 model not foundThe model name after asi/ is misspelled. Use asi1, asi1-ultra, asi1-ultra-1m or asi1-mini.

Next steps

  1. Codex: the same models in the Codex CLI
  2. Cursor: the same models in the Cursor editor
  3. ASI:One Models: choosing between asi1, asi1-ultra, asi1-ultra-1m and asi1-mini
  4. Chat Completions API: the endpoint OpenCode talks to