How to Connect Bluehost AI Credits to Claude Code
This article covers connecting an AI Credits API key to Claude Code so it can run against your AI Credits balance instead of billing directly to Anthropic. It assumes Claude Code is already installed on your Self-Managed VPS or VDS. Use Section 1 if you've never run Claude Code before, or Section 2 if it's already set up and signed in.
Before you begin: You'll need an AI Credits API key. If you haven't created one yet, see How to Manage Your Bluehost API Keys first. Your gateway endpoint is https://gateway.ai.bluehost.com/.
Section 1: First-Time Setup (Claude Code Never Run Before)
If you've just installed Claude Code and haven't run it yet, set your AI Credits connection using ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL as shell environment variables — this is the method confirmed to skip Claude Code's Anthropic sign-in screen entirely.
- Open a terminal on your local computer and connect over SSH, replacing
YOUR_SERVER_IPwith your server's IP address:ssh root@YOUR_SERVER_IP - Persist your AI Credits key and gateway endpoint to your shell profile:
echo 'export ANTHROPIC_API_KEY="YOUR_AI_CREDITS_API_KEY"' >> /root/.profile echo 'export ANTHROPIC_BASE_URL="https://gateway.ai.bluehost.com"' >> /root/.profile
- Load the profile into your current shell:
source /root/.profile
- Confirm Claude Code is installed, then start it:
claude --version claude
With ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL already set, Claude Code skips the Anthropic sign-in screen entirely and goes straight into a working session:
root@YOUR_SERVER_IP:~# echo 'export ANTHROPIC_API_KEY="YOUR_AI_CREDITS_API_KEY"' >> /root/.profile echo 'export ANTHROPIC_BASE_URL="https://gateway.ai.bluehost.com"' >> /root/.profile root@YOUR_SERVER_IP:~# source /root/.profile root@YOUR_SERVER_IP:~# claude --version 2.1.126 (Claude Code) root@YOUR_SERVER_IP:~# claude ╭─── Claude Code v2.1.126 ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ │ Tips for getting started │ │ Welcome back! │ Run /init to create a CLAUDE.md file with instructions for Claude │ │ │ Note: You have launched claude in your home directory. For the best experience, launch it in a project directory in… │ │ ▐▛███▜▌ │ ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────── │ │ ▝▜█████▛▘ │ What's new │ │ ▘▘ ▝▝ │ Bug fixes and reliability improvements │ │ │ Bug fixes and reliability improvements │ │ Sonnet 4.6 · API Usage Billing │ Cost estimates (`/cost`, status line, `--max-budget-usd`) now include the 1.1× US-only-inference premium for data-r… │ │ /root │ /release-notes for more │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ❯ hi ● Hi! How can I help you today? ✻ Cogitated for 2s ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ❯ ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ? for shortcuts
No default model? Claude Code picks a default (Sonnet 4.6 in this example) when none is specified. To choose a specific model instead, use /model inside a session, or set ANTHROPIC_DEFAULT_MODEL alongside the variables above — see AI Models and Credit Pricing for available model IDs.
Section 2: Connecting AI Credits to an Existing Claude Code Install
Not yet verified. Section 1's method (ANTHROPIC_API_KEY + ANTHROPIC_BASE_URL via shell profile) was confirmed on a live server. The steps below, for an already-signed-in install, haven't been retested the same way and use ANTHROPIC_AUTH_TOKEN rather than the confirmed ANTHROPIC_API_KEY approach. If you have an existing Claude Code login, it's safer to log out first, then follow Section 1's steps instead of the untested steps below.
If Claude Code is already installed and you've previously signed in (via Claude subscription login or an Anthropic Console API key), that existing login takes priority over ANTHROPIC_BASE_URL unless you clear it first.
- Start Claude Code and log out of the existing session:
Then, inside the session, run:claude/logout
- Exit Claude Code, then follow Section 1's steps 2–4 above to set
ANTHROPIC_API_KEYandANTHROPIC_BASE_URLand relaunch.
Testing the Connection
From within a Claude Code session, run a simple prompt to confirm it's responding through the gateway:
If you get a normal response with no authentication errors, Claude Code is successfully routing through your AI Credits gateway.
Choosing a model: Claude Code can use any Claude model available through your AI Credits gateway. Credit cost varies by model — see AI Models and Credit Pricing before picking a default for heavier workloads.
Authentication errors: A 401 or similar auth failure usually means either the endpoint doesn't accept the key the way Claude Code sends it, or the endpoint isn't returning responses in the format Claude Code expects. Double-check the gateway endpoint URL and key, and confirm with Bluehost support if the issue persists.
Summary
For a fresh Claude Code install, set ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL as shell environment variables (persisted via /root/.profile) before your first launch — this is the confirmed way to skip Claude Code's Anthropic sign-in screen entirely. For an install that's already signed in, run /logout first, then follow the same steps. Either way, test with a simple prompt before relying on it for real work.