Command-line agents
OpenCode
Add NoviaHub to OpenCode as a custom provider and write code with NoviaHub models.
OpenCode is an open source AI coding agent, available as a terminal interface, a desktop app and an IDE extension. Its config file can add “custom providers”, which it calls over an OpenAI-compatible API, so it can use models on NoviaHub.
Prerequisites
Section titled “Prerequisites”- A NoviaHub API key. If you don’t have one yet, see API keys.
- Funds in your account. Calls are charged to your balance by usage.
Install
Section titled “Install”Use any of the official install methods:
curl -fsSL https://opencode.ai/install | bashnpm install -g opencode-aibun and pnpm can install the same package too.
brew install anomalyco/tap/opencodesudo pacman -S opencode# orparu -S opencode-binchoco install opencode# orscoop install opencodeOn Windows, OpenCode recommends running it through WSL.
Configure NoviaHub
Section titled “Configure NoviaHub”-
Store the API key in the environment variable
NOVIAHUB_API_KEY. The config file only names the variable; it never holds the key itself.终端窗口 # Add this line to the end of ~/.zshrc or ~/.bashrc, then open a new terminalexport NOVIAHUB_API_KEY="sk-..."终端窗口 setx NOVIAHUB_API_KEY "sk-..."# Close the terminal and open a new one; the variable only exists in new windows -
Edit the config file
~/.config/opencode/opencode.json(create it if needed) and add:~/.config/opencode/opencode.json {"$schema": "https://opencode.ai/config.json","provider": {"noviahub": {"npm": "@ai-sdk/openai-compatible","name": "NoviaHub","options": {"baseURL": "https://noviahub.com/v1","apiKey": "{env:NOVIAHUB_API_KEY}"},"models": {"deepseek-v4-flash": {"name": "deepseek-v4-flash","limit": { "context": 1000000, "output": 384000 }},"claude-sonnet-5": {"name": "claude-sonnet-5","limit": { "context": 1000000, "output": 64000 }}}}},"model": "noviahub/deepseek-v4-flash"}What each field means:
Field Meaning noviahubThe provider ID. Any name works; you refer to models as noviahub/<model ID>.npm@ai-sdk/openai-compatiblecalls/v1/chat/completions.options.baseURLMust include /v1:https://noviahub.com/v1.options.apiKey{env:NOVIAHUB_API_KEY}reads the key from the environment variable.modelsThe models to use. Each key is a model ID on NoviaHub and must match exactly. limit.context/limit.outputPer OpenCode’s docs, limit.contextis the most input tokens the model accepts andlimit.outputthe most tokens it can generate; OpenCode uses them to work out how much context is left. The example values are the Context and Max output shown on Models & Pricing on 2026-09-28; the page is authoritative.modelThe default model, as <provider ID>/<model ID>.To apply the settings to one project only, put the same content in
opencode.jsonat the project root instead. -
Run
opencodein your project directory.
Verify
Section titled “Verify”# List the models configured under the noviahub provideropencode models noviahub
# Send one message without opening the interfaceopencode run -m noviahub/deepseek-v4-flash "Introduce yourself in one sentence."If you get a reply and the call shows up under Usage Logs in NoviaHub, the setup works.
Switch models
Section titled “Switch models”- In OpenCode, type
/modelsand pick one. - At launch:
opencode --model noviahub/claude-sonnet-5(or-m). - Change
modelin the config file to set the default.
Add a model to models in the config file before using it. This config uses the OpenAI Chat API, so it only works with models that carry the Chat endpoint label under Models & Pricing (every text model had it on 2026-09-28).
- If a model supports only the Responses API (its page shows Response but not Chat), change that provider’s
npmto@ai-sdk/openai. - It works without
limit, but then OpenCode can’t tell accurately how much context is left. - Instead of the config file, you can also run
/connect→ Other in OpenCode and enter a provider ID and key; the key is saved in~/.local/share/opencode/auth.json.opencode auth listshows saved keys.
References
Section titled “References”Checked on 2026-09-28:
- OpenCode overview and install: opencode.ai/docs
- Custom providers: opencode.ai/docs/providers
- Config file: opencode.ai/docs/config
- Choosing models: opencode.ai/docs/models
- CLI: opencode.ai/docs/cli