OpenCode

Setting Up OpenCode

A step-by-step guide to configure HyprLab API as your AI provider in OpenCode.

Prerequisites

Step 1: the Config File

Create or edit ~/.config/opencode/opencode.json. Choose the provider format based on your needs:

Option A: OpenAI Format (All Models)

Use @ai-sdk/openai-compatible to access any model via OpenAI-compatible API:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "hyprlab-oai": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "HyprLab (OpenAI)",
      "options": {
        "baseURL": "https://api.hyprlab.io/v1"
      },
      "models": {
        "gpt-5.2": {
          "name": "GPT-5.2",
          "cost": { "input": 1.225, "output": 9.8 },
          "limit": { "context": 200000, "output": 32768 }
        },
        "gpt-5.2-pro": {
          "name": "GPT-5.2 Pro",
          "cost": { "input": 18.9, "output": 151.2 },
          "limit": { "context": 200000, "output": 32768 }
        }
      }
    }
  }
}

Option B: Anthropic Format (Claude Models)

Use @ai-sdk/anthropic for native Claude API format:

Option C: Google Format (Gemini Models)

Use @ai-sdk/google for native Google AI format:

Tip: You can combine all three providers in one config file.

Step 2: Authenticate with HyprLab

Run the authentication command:

When prompted:

  1. Search for hyprlab (or your provider name from config)

  2. Enter your HyprLab API key

Your credentials are stored in ~/.local/share/opencode/auth.json.


Step 3: Start OpenCode

Launch OpenCode:

Step 4: Select Your Model

In the OpenCode TUI:

  1. Use /models command to open the model picker

  2. Select a HyprLab model

Step 5: Send Your First Message

Type your message and press Enter. You're now using HyprLab!

Configuration Reference

Model Properties

Property
Description
Example

name

Display name

"Gemini 3 Pro"

cost.input

Cost per 1M input tokens

0.8

cost.output

Cost per 1M output tokens

4.8

limit.context

Max context window (tokens)

1048576

limit.output

Max output tokens per response

65536

reasoning

Supports thinking/reasoning

true

modalities.input

Input types supported

["text", "image"]

modalities.output

Output types supported

["text"]

Available Providers

Provider ID
SDK
Use For

hyprlab-oai

@ai-sdk/openai-compatible

All models via OpenAI format

hyprlab-claude

@ai-sdk/anthropic

Claude models (native format)

hyprlab-google

@ai-sdk/google

Gemini models (native format)

Base URLs

Provider
Base URL

OpenAI format

https://api.hyprlab.io/v1

Claude format

https://api.hyprlab.io/v1

Google format

https://api.hyprlab.io/v1beta

Troubleshooting

"Unauthorized" Error

  • Run opencode auth login and re-enter your API key

  • Verify your API key

Model Not Showing

  • Ensure your opencode.json has valid JSON syntax

  • Restart OpenCode after config changes

Wrong Pricing/Context Shown

Last updated