Inference Providers documentation

OpenCode

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

OpenCode

OpenCode is an AI coding agent built for the terminal that helps with code review, refactoring, testing, and general development tasks.

Overview

OpenCode natively supports Hugging Face Inference Providers, giving you access to open models from 17+ providers through a single interface.

Prerequisites

  • OpenCode installed (installation guide)
  • A Hugging Face account with API token (needs “Make calls to Inference Providers” permission)

Configuration

Quick Setup

  1. Create a Hugging Face token with Inference Providers permissions at huggingface.co/settings/tokens

  2. Run opencode auth login and select Hugging Face:

$ opencode auth login

┌  Add credential
│
◆  Select provider
│  ● Hugging Face
│  ...
└
  1. Enter your Hugging Face token when prompted:
┌  Add credential
│
◇  Select provider
│  Hugging Face
│
◇  Enter your API key
│  hf_...
└
  1. Run the /models command 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).

GitHub Actions Integration

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.

Resources

Update on GitHub