opencode Integration
Bring Ask Sage AI directly into VS Code with the opencode extension and CLI
Use opencode for VS Code with Ask Sage as your AI provider — all inference stays within your organization's approved instance.
Table of Contents
Instance-Specific Base URL: The endpoints and configuration shown reflect the instance at chat.asksage.ai. The api. prefix and path suffix stay the same across deployments — only the instance segment in the middle changes based on which Ask Sage instance you are logging into. Always use the instance approved by your organization and applicable regulatory requirements, and match the base URL in your configuration to the instance you authenticate against.
Prerequisites
Before you begin, ensure you have the following:
opencode CLI
Install from opencode.ai
VS Code Extension
Install from the VS Code Marketplace
Installation
Step 1: Install the opencode CLI
Step 2: Install the VS Code Extension
code --install-extension sst-dev.opencode from your terminal. Configuration
opencode reads its configuration from opencode.json. Create or update this file in your project root (or globally at ~/.config/opencode/opencode.json) with the following:
- Project-level:
opencode.jsonin your project root - Global:
~/.config/opencode/opencode.json(Mac/Linux) or%APPDATA%\opencode\opencode.json(Windows)
opencode.json — Ask Sage GPT-5.5 Example
{
"$schema": "https://opencode.ai/config.json",
"model": "asksage/gpt-5.5",
"provider": {
"asksage": {
"npm": "@ai-sdk/openai",
"name": "Ask Sage",
"options": {
"baseURL": "https://api.asksage.ai/server/openai/v1",
"apiKey": "YOUR_API_KEY"
},
"models": {
"gpt-5.5": {
"name": "GPT-5.5",
"limit": {
"context": 128000,
"output": 16384
}
}
}
}
}
}YOUR_API_KEY with your actual Ask Sage API key. The model field at the top sets the default model — it must use the format asksage/<model-key> where the model key matches one of the entries under models. - Production:
https://api.asksage.ai/server/openai/v1 - Army GenAI:
https://api.genai.army.mil/server/openai/v1
Claude Model Configuration
Claude models use Anthropic's native API format. Add a second provider block to your opencode.json using @ai-sdk/anthropic pointed at Ask Sage's Anthropic-compatible endpoint:
opencode.json — Ask Sage Claude 4.8 Opus Example
{
"$schema": "https://opencode.ai/config.json",
"model": "asksage-claude/google-claude-48-opus",
"provider": {
"asksage-claude": {
"npm": "@ai-sdk/anthropic",
"name": "Ask Sage (Claude)",
"options": {
"baseURL": "https://api.asksage.ai/server/anthropic/v1",
"apiKey": "YOUR_API_KEY"
},
"models": {
"google-claude-48-opus": {
"name": "Claude 4.8 Opus",
"limit": {
"context": 200000,
"output": 32000
}
}
}
}
}
}- Production:
https://api.asksage.ai/server/anthropic/v1 - Army GenAI:
https://api.genai.army.mil/server/anthropic/v1
opencode.json and switch between them by changing the top-level model field — e.g. asksage/gpt-5.5 or asksage-claude/google-claude-48-opus. Reload the VS Code window after any config change. YOUR_API_KEY with your actual Ask Sage API key. Using Environment Variables for the API Key
To avoid storing your API key in plaintext inside opencode.json, use opencode's environment variable substitution syntax:
{
"$schema": "https://opencode.ai/config.json",
"model": "asksage/gpt-5.5",
"provider": {
"asksage": {
"npm": "@ai-sdk/openai",
"name": "Ask Sage",
"options": {
"baseURL": "https://api.asksage.ai/server/openai/v1",
"apiKey": "{env:ASKSAGE_API_KEY}"
},
"models": {
"gpt-5.5": {
"name": "GPT-5.5",
"limit": { "context": 128000, "output": 16384 }
}
}
}
}
}Then export the key in your shell profile or session before launching opencode:
export ASKSAGE_API_KEY="your-api-key-here"Privacy & Non-Essential Traffic
By default, opencode can make outbound connections beyond model inference — for update checks, session sharing, and local network discovery. In regulated environments, add the following fields to opencode.json to restrict traffic to Ask Sage only:
{
"$schema": "https://opencode.ai/config.json",
"model": "asksage-claude/google-claude-48-opus",
"autoupdate": false,
"share": "disabled",
"server": {
"mdns": false
},
"provider": {
...
}
}Launching opencode in VS Code
Once installed, the VS Code extension provides keyboard shortcuts to launch opencode directly inside your editor:
Activation & Testing
Features & Capabilities
Troubleshooting
opencode returns a 401 or authentication failure
Solutions:
- ✅ Verify your Ask Sage API key is correct (no extra spaces or newlines)
- ✅ If using
{env:ASKSAGE_API_KEY}, confirm the variable is exported in the shell where VS Code was launched - ✅ Confirm the key has not expired — regenerate from your Ask Sage account settings if needed
opencode reports the model is unavailable
Solutions:
- ✅ Confirm the model key in
opencode.jsonexactly matches the key used by your Ask Sage instance (check via the Ask Sage/get-modelsendpoint) - ✅ Ensure the
"model"top-level field uses the formatasksage/<model-key> - ✅ Verify the model is enabled on your tenant
Requests fail to reach the Ask Sage API
Solutions:
- ✅ Double-check the
baseURLmatches your organization's Ask Sage instance - ✅ Ensure the trailing slash is present:
https://api.asksage.ai/server/ - ✅ Check firewall or proxy settings — opencode must be able to reach the API endpoint
- ✅ If on a government network, confirm you are connected to the required VPN
Keyboard shortcut opens a terminal but opencode doesn't start
Solutions:
- ✅ Confirm
opencodeis in your systemPATH(runopencode --versionin a terminal) - ✅ Restart VS Code after installing the CLI so the updated PATH is picked up
- ✅ On Windows, ensure the npm global bin directory is in your PATH
Additional Resources
Documentation
- opencode Official Documentation
- opencode Configuration Reference
- opencode Provider Configuration
- opencode VS Code Extension
- Ask Sage API Documentation
Support
- Email: support@asksage.ai
- Documentation: https://docs.asksage.ai
If you encounter issues not covered here, reach out to support@asksage.ai with:
- Your OS and VS Code version
- opencode CLI version (
opencode --version) - Relevant error messages from the opencode terminal output
- Your
opencode.json(with API key redacted)