OpenCode
OpenCode is a terminal coding agent that supports custom model providers through the AI SDK. Configure NexoAI once at user level, then select its models from the TUI in any project.
Install
bash
npm install -g opencode-aiStart OpenCode once to confirm the CLI is available:
bash
opencodeAdd the nexoai provider
The global configuration file is ~/.config/opencode/opencode.json. Create the directory if it does not exist:
bash
mkdir -p ~/.config/opencodeSet the named NexoAI key in the shell environment used to launch OpenCode:
bash
export NEXOAI_API_KEY="sk-your-nexoai-key"Add this user-level provider configuration:
json
{
"$schema": "https://opencode.ai/config.json",
"model": "nexoai/gpt-5.6-sol",
"provider": {
"nexoai": {
"npm": "@ai-sdk/openai-compatible",
"name": "NexoAI",
"options": {
"baseURL": "https://api.nexoai.ma/v1",
"apiKey": "{env:NEXOAI_API_KEY}"
},
"models": {
"gpt-5.6-sol": {
"name": "GPT 5.6 Sol"
},
"claude-opus-4-8": {
"name": "Claude Opus 4.8"
},
"qwen3.7-plus": {
"name": "Qwen 3.7 Plus"
}
}
}
}
}The provider ID is nexoai. @ai-sdk/openai-compatible sends OpenAI-compatible chat-completions requests to the versioned NexoAI base, while apiKey resolves the credential without placing it in the JSON file.
Add only models you plan to use
The models map controls what appears in OpenCode's picker. Every ID above is in the live NexoAI catalog; add another exact ID only when it carries the openai endpoint badge and your named key has access to its family.
Keep credentials user-scoped
Do not put sk-your-nexoai-key directly into a project-level opencode.json. Use the environment reference above, a shell secret manager, or OpenCode's /connect flow with provider ID nexoai.
Verify
Restart opencode, then open the model picker inside the TUI:
text
/modelsChoose a model under NexoAI, send a small repository question, and check the named key's usage in the NexoAI dashboard. If the provider does not appear, verify that ~/.config/opencode/opencode.json is valid JSON and that the nexoai ID matches everywhere.
