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 omgvibeThis configures your environment automatically. For manual setup, continue reading.
Installation
curl -fsSL https://claude.ai/install.sh | bashnpm 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.
Settings File (Recommended)
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
| Variable | Value | Required |
|---|---|---|
ANTHROPIC_API_KEY | Your OhMyGPT API key | Yes |
ANTHROPIC_BASE_URL | https://c-z0-api-01.hash070.com/api/v1/ai/openai/cc-omg/ | Yes |
DISABLE_TELEMETRY | 1 | Optional |
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC | 1 | Optional |
Settings File Fields
These fields are set at the top level of settings.json (not inside env):
| Field | Type | Description |
|---|---|---|
model | string | Model tier to use: opus, sonnet, or haiku |
apiKeyHelper | string | Shell command that outputs the API key (alternative to hardcoding in env) |
includeCoAuthoredBy | boolean | Include "Co-authored-by: Claude" in git commits |
permissions | object | Tool 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:
| Value | Description |
|---|---|
opus | Highest capability, best for complex architectural tasks |
sonnet | Balanced performance and speed (default) |
haiku | Fastest 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:
| Variable | Default Tier |
|---|---|
ANTHROPIC_DEFAULT_OPUS_MODEL | opus |
ANTHROPIC_DEFAULT_SONNET_MODEL | sonnet |
ANTHROPIC_DEFAULT_HAIKU_MODEL | haiku |
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
| Symptom | Cause | Solution |
|---|---|---|
| "Invalid API key" | Key not set or incorrect | Verify ANTHROPIC_API_KEY contains your OhMyGPT key |
| "Connection refused" | Wrong base URL | Ensure ANTHROPIC_BASE_URL is set correctly |
| "Model not found" | Unsupported model tier | Use opus, sonnet, or haiku for the model field |
| Prompts for login | Config not loaded | Select "Use your own API key" when prompted; verify settings file path |
| Tool use errors | Model limitation | Claude Code requires tool use; ensure you're using a supported model |
| Context length errors | Conversation too long | Start a new session with /clear or switch to a model with larger context |
How is this guide?
Last updated on
