OpenCode is an AI coding agent built for the terminal that helps with code review, refactoring, testing, and general development tasks.
OpenCode natively supports Hugging Face Inference Providers, giving you access to open models from 17+ providers through a single interface.
- OpenCode installed (installation guide)
- A Hugging Face account with API token (needs "Make calls to Inference Providers" permission)
-
Create a Hugging Face token with Inference Providers permissions at huggingface.co/settings/tokens
-
Run
opencode auth loginand select Hugging Face:
$ opencode auth login
┌ Add credential
│
◆ Select provider
│ ● Hugging Face
│ ...
└- Enter your Hugging Face token when prompted:
┌ Add credential
│
◇ Select provider
│ Hugging Face
│
◇ Enter your API key
│ hf_...
└- Run the
/modelscommand in OpenCode to select a model.
Once configured, OpenCode will use your selected model for all operations. You can switch models anytime using the /models command in the OpenCode TUI (Terminal User Interface).
OpenCode can also be used to run open models in GitHub Actions via Inference Providers. See our GitHub Actions guide for setting up automated PR reviews.