Use ZhiFlo in OpenCode
OpenCode can keep the Token in its local credential store while the provider address and models remain in user-level configuration. When setup is complete, /models will list the ZhiFlo model for selection.
Before you start
Section titled “Before you start”- Install OpenCode from its official documentation, then confirm that
opencode --versionprints version information. - Create a Token for this device.
- Copy a complete model ID from your account.
Store the Token
Section titled “Store the Token”- Run
opencodein a terminal. - Enter
/connectin OpenCode. - Select Other.
- Enter the Provider ID
zhiflo. - Paste your ZhiFlo Token at the credential prompt.
The Provider ID must exactly match the zhiflo key in the next section. OpenCode stores this Token locally; do not duplicate it in the JSON file.
Add the ZhiFlo provider
Section titled “Add the ZhiFlo provider”Open the global configuration file:
~/.config/opencode/opencode.jsonOn Windows, ~ means your user home directory. If the file already has settings, merge provider.zhiflo into the existing JSON instead of replacing the file.
{ "$schema": "https://opencode.ai/config.json", "provider": { "zhiflo": { "npm": "@ai-sdk/openai-compatible", "name": "ZhiFlo", "options": { "baseURL": "https://api.zhiflo.com/v1" }, "models": { "<MODEL_FROM_ZHIFLO>": { "name": "<MODEL_FROM_ZHIFLO>" } } } }}Replace both <MODEL_FROM_ZHIFLO> values with the same complete model ID. The outer key is the server-recognized ID; name is a local label. Keeping them identical avoids ambiguity during initial setup.
Save the file, exit OpenCode, and run opencode again so the global configuration is reloaded.
Select the model and send a message
Section titled “Select the model and send a message”-
Enter
/models. -
Find and select the model under
zhiflo. -
From an empty folder or a project without important files, send:
Do not modify any files. Reply with OK only.
Seeing the model in /models confirms that configuration loaded. Receiving OK also confirms the Token, address, model, and request.
If the model or reply is missing
Section titled “If the model or reply is missing”- No
zhifloentry in/models: check the file location, JSON commas and braces, and the Provider ID entered through/connect. - The model appears but returns
401: run/connect→ Other →zhifloagain and update the locally stored Token. 404response: setbaseURLtohttps://api.zhiflo.com/v1; do not append/chat/completionsthere.- Model not found: make the configuration key exactly match the current account model ID, then reopen OpenCode.
Do not run OpenCode as an administrator or with sudo to solve a normal configuration problem. That expands its permissions and may create files owned by the wrong user.