Skip to content

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.

  • Install OpenCode from its official documentation, then confirm that opencode --version prints version information.
  • Create a Token for this device.
  • Copy a complete model ID from your account.
  1. Run opencode in a terminal.
  2. Enter /connect in OpenCode.
  3. Select Other.
  4. Enter the Provider ID zhiflo.
  5. 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.

Open the global configuration file:

~/.config/opencode/opencode.json

On 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.

  1. Enter /models.

  2. Find and select the model under zhiflo.

  3. 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.

  • No zhiflo entry in /models: check the file location, JSON commas and braces, and the Provider ID entered through /connect.
  • The model appears but returns 401: run /connectOtherzhiflo again and update the locally stored Token.
  • 404 response: set baseURL to https://api.zhiflo.com/v1; do not append /chat/completions there.
  • 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.

Next: Troubleshoot shared connection issues.