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. This guide connects it to OhMyGPT so you can pay-as-you-go without an Anthropic subscription.

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+.

Manual Configuration

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

export ANTHROPIC_BASE_URL="https://api.ohmygpt.com/code-assist/v1"
export ANTHROPIC_API_KEY="<your-ohmygpt-api-key>"

Option 2: User Settings File

Edit ~/.claude/settings.json for user-wide configuration:

{
  "env": {
    "ANTHROPIC_API_KEY": "<your-ohmygpt-api-key>",
    "ANTHROPIC_BASE_URL": "https://api.ohmygpt.com/code-assist/v1"
  }
}

Option 3: Project Settings File

Create .claude/settings.local.json in your project root for project-specific configuration:

{
  "env": {
    "ANTHROPIC_API_KEY": "<your-ohmygpt-api-key>",
    "ANTHROPIC_BASE_URL": "https://api.ohmygpt.com/code-assist/v1"
  }
}

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

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

Configuration Reference

VariableValueRequired
ANTHROPIC_BASE_URLhttps://api.ohmygpt.com/code-assist/v1Yes
ANTHROPIC_API_KEYYour OhMyGPT API keyYes
DISABLE_TELEMETRY1Optional
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC1Optional

Verification

After configuration, start Claude Code and run the /status command:

claude
> /status
Anthropic base URL: https://api.ohmygpt.com/code-assist/v1

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

GitHub Actions

Use Claude Code in CI/CD workflows to automate code reviews and issue responses.

Setup

Add these secrets to your repository:

SecretValue
ANTHROPIC_API_KEYYour OhMyGPT API key
ANTHROPIC_BASE_URLhttps://api.ohmygpt.com/code-assist/v1

Workflow Example

Create .github/workflows/claude.yml:

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@beta
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
          timeout_minutes: "60"
          claude_env: |
            ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }}
            DISABLE_TELEMETRY: 1

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

How It Works

OhMyGPT exposes an endpoint fully compatible with the Anthropic Messages API:

  1. Direct Connection — Setting ANTHROPIC_BASE_URL routes Claude Code's native protocol directly to OhMyGPT. No local proxy is required.
  2. API Compatibility — OhMyGPT handles model mapping and passes through advanced features like extended thinking and native tool use.
  3. Pay-as-you-go — You are billed using your OhMyGPT balance. Usage appears in your OhMyGPT dashboard.

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 https://api.ohmygpt.com/code-assist/v1
"Model not found"Using unsupported modelVerify model name is correct
Prompts for API keyConfig not loadedSelect "Yes" when prompted, or check settings file path
Tool use errorsModel doesn't support toolsClaude Code requires tool use; ensure you're using a supported model
Context length errorsConversation too longStart a new session or use a model with larger context window

API Reference

ItemValue
Base URLhttps://api.ohmygpt.com/code-assist/v1
EndpointPOST /messages
Auth HeaderAuthorization: Bearer <api-key>
Content-Typeapplication/json

Request and response formats follow the Anthropic Messages API specification.

How is this guide?

Last updated on

On this page