OhMyGPT
Code CLI

Claude Code

Configure Claude Code CLI to use OhMyGPT as the API provider.

Claude Code is Anthropic's official agentic coding tool that operates directly in your terminal. By pointing its ANTHROPIC_BASE_URL at OhMyGPT, all requests are routed through OhMyGPT's Anthropic-compatible endpoint — no local proxy required.

Quick Setup

Run the interactive installer:

npx omgvibe

This configures your environment automatically. For manual setup, continue reading.

Installation

curl -fsSL https://claude.ai/install.sh | bash

npm installation requires Node.js 18+.

Configuration

Claude Code reads configuration from settings files (~/.claude/settings.json for user-wide, .claude/settings.local.json for project-level) or shell environment variables. The settings file approach is recommended because it persists across sessions and keeps all options in one place.

Edit ~/.claude/settings.json:

{
  "env": {
    "ANTHROPIC_API_KEY": "<your-ohmygpt-api-key>",
    "ANTHROPIC_BASE_URL": "https://c-z0-api-01.hash070.com/api/v1/ai/openai/cc-omg/",
    "DISABLE_TELEMETRY": "1",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  },
  "model": "sonnet"
}

For project-scoped configuration, create .claude/settings.local.json in your project root instead. Project settings override user settings.

Add .claude/settings.local.json to .gitignore to avoid committing your API key.

Shell Environment Variables

Alternatively, add to your shell profile (~/.bashrc, ~/.zshrc, or ~/.config/fish/config.fish):

export ANTHROPIC_BASE_URL="https://c-z0-api-01.hash070.com/api/v1/ai/openai/cc-omg/"
export ANTHROPIC_API_KEY="<your-ohmygpt-api-key>"

Do not use a project-level .env file — Claude Code does not read standard .env files.

Configuration Reference

Environment Variables

VariableValueRequired
ANTHROPIC_API_KEYYour OhMyGPT API keyYes
ANTHROPIC_BASE_URLhttps://c-z0-api-01.hash070.com/api/v1/ai/openai/cc-omg/Yes
DISABLE_TELEMETRY1Optional
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC1Optional

Settings File Fields

These fields are set at the top level of settings.json (not inside env):

FieldTypeDescription
modelstringModel tier to use: opus, sonnet, or haiku
apiKeyHelperstringShell command that outputs the API key (alternative to hardcoding in env)
includeCoAuthoredBybooleanInclude "Co-authored-by: Claude" in git commits
permissionsobjectTool permission rules (allow and deny arrays)

Using apiKeyHelper avoids storing the key in plaintext:

{
  "apiKeyHelper": "cat ~/.secrets/ohmygpt-key",
  "env": {
    "ANTHROPIC_BASE_URL": "https://c-z0-api-01.hash070.com/api/v1/ai/openai/cc-omg/",
    "DISABLE_TELEMETRY": "1",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  },
  "model": "sonnet"
}

Model Selection

Set the model field in your settings file to choose the model tier:

ValueDescription
opusHighest capability, best for complex architectural tasks
sonnetBalanced performance and speed (default)
haikuFastest responses, suitable for simpler tasks
{
  "model": "opus"
}

Overriding Default Models

Claude Code maps each tier (opus, sonnet, haiku) to a specific model. You can override these mappings via environment variables to route requests to different models available on OhMyGPT:

VariableDefault Tier
ANTHROPIC_DEFAULT_OPUS_MODELopus
ANTHROPIC_DEFAULT_SONNET_MODELsonnet
ANTHROPIC_DEFAULT_HAIKU_MODELhaiku

Example — use a specific model for the sonnet tier:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://c-z0-api-01.hash070.com/api/v1/ai/openai/cc-omg/",
    "ANTHROPIC_API_KEY": "<your-ohmygpt-api-key>",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-4-20250514"
  },
  "model": "sonnet"
}

These are Claude Code built-in variables that work regardless of provider. When set, Claude Code sends the specified model name in API requests instead of the default alias.

Verification

Start Claude Code and run /status:

> /status
Anthropic base URL: https://c-z0-api-01.hash070.com/api/v1/ai/openai/cc-omg/

If the base URL shows the OhMyGPT endpoint, your configuration is active.

GitHub Actions

Use Claude Code in CI/CD workflows with the official claude-code-action. Add your OhMyGPT API key and base URL as repository secrets, then reference them in your workflow:

name: Claude Assistant

on:
  issue_comment:
    types: [created]
  pull_request_review_comment:
    types: [created]

jobs:
  claude:
    if: contains(github.event.comment.body, '@claude')
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
      issues: write
    steps:
      - uses: actions/checkout@v4

      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
        env:
          ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
          DISABLE_TELEMETRY: "1"

Mention @claude in any issue or PR comment to trigger the assistant.

Agent SDK

The Anthropic Agent SDK uses Claude Code as its runtime. Since the Agent SDK reads the same ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY environment variables, no additional configuration is needed — setting up Claude Code with OhMyGPT automatically applies to Agent SDK usage as well.

Troubleshooting

SymptomCauseSolution
"Invalid API key"Key not set or incorrectVerify ANTHROPIC_API_KEY contains your OhMyGPT key
"Connection refused"Wrong base URLEnsure ANTHROPIC_BASE_URL is set correctly
"Model not found"Unsupported model tierUse opus, sonnet, or haiku for the model field
Prompts for loginConfig not loadedSelect "Use your own API key" when prompted; verify settings file path
Tool use errorsModel limitationClaude Code requires tool use; ensure you're using a supported model
Context length errorsConversation too longStart a new session with /clear or switch to a model with larger context

How is this guide?

Last updated on

On this page