Skip to main content

Claude Code with OpenCheese

/ API docs

← API quickstartView as Markdown

Claude Code talks to the Anthropic Messages API, which OpenCheese serves at https://api.opencheese.dev. Point it there with an OpenCheese API key and it runs on the models enabled for your account.

The fastest way: the generated file

Sign in, open Configuration, choose the Claude Code tab with Claude Code (CLI) selected, pick an API key and confirm your password. Copy the generated settings.json and merge its env block into your user settings:

System File
macOS and Linux ~/.claude/settings.json
Windows %USERPROFILE%\.claude\settings.json

The generated file pins the newest Claude models your plan includes to Claude Code's model aliases (opus, sonnet, haiku and fable), so /model opus and the others resolve to models you can use. A family your plan does not include is left out.

Manual setup

json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.opencheese.dev",
    "ANTHROPIC_API_KEY": "YOUR_OPENCHEESE_API_KEY",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "OPUS_MODEL_ID",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "SONNET_MODEL_ID",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "HAIKU_MODEL_ID",
    "ANTHROPIC_DEFAULT_FABLE_MODEL": "FABLE_MODEL_ID"
  }
}
  • ANTHROPIC_BASE_URL must not end in /v1: Claude Code appends /v1/messages itself.
  • Take the model IDs from GET /v1/models with your key (see Models).
  • Merge the keys into your existing file so your permissions, hooks and MCP settings survive.
  • Keep it in your user settings. A .claude/settings.json committed to a repository publishes your API key to everyone with access to it.

Switch models

Inside Claude Code, use /model with an alias such as opus, sonnet, haiku or fable; each resolves to the model pinned in your settings. Claude Code reloads settings.json while it runs, but reads the alias mapping at startup, so restart it after changing an alias.

The effort level you choose in Claude Code is sent with every request. A level the model does not offer is refused with a message naming the levels it does.

In VS Code, Cursor and JetBrains IDEs

The Claude Code extension for VS Code and Cursor, and the JetBrains plugin, use the same ~/.claude/settings.json, so the setup above covers them too. See VS Code and JetBrains.

Claude Desktop

The same Claude Code tab has a Claude Desktop switch. Claude Desktop takes a file you download and import inside the app; see Claude Desktop.

Usage and costs

Every request appears under Transactions in the dashboard, grouped as one session per conversation, with its token usage and cost.

Troubleshooting

  • "Invalid or disabled OpenCheese API key": the key was revoked, disabled or copied incompletely. Check it on the API keys page and regenerate the configuration.
  • The website answers instead of the API: the base URL must be https://api.opencheese.dev, not https://opencheese.dev.
  • Requests fail with a doubled path: a base URL ending in /v1 sends Claude Code to /v1/v1/messages. Remove the /v1.
  • "Not included in your current plan": the model is outside your plan. Choose another model, or keep Use balance for Credit Models on in the Overview page to pay for it from your balance.
The cheese has holes. Your infrastructure should not.