Convert Claude Pro to API Using VPS and FastAPI
A technical workaround allows Claude Pro subscribers to create their own API endpoint by running a VPS with Claude Code SDK and FastAPI, bypassing separate API
DIY API: Turn Claude Pro Into API Access Via VPS
What It Is
A workaround has emerged that lets Claude Pro subscribers create their own API endpoint without purchasing separate API credits. The technique involves running a Virtual Private Server (VPS) that authenticates with a Claude Pro account through the Claude Code SDK, then wrapping that connection in a FastAPI server. This creates a functional HTTP endpoint that accepts requests and returns Claude’s responses, essentially converting the web-based subscription into programmatic access.
The approach relies on the Claude Code SDK, which was designed for IDE integrations but can be repurposed for broader automation. By hosting this setup on a VPS rather than a local machine, developers gain a persistent endpoint accessible from anywhere. Several cloud providers offer generous free tiers - DigitalOcean provides $200 in credits for new accounts, which covers months of basic VPS hosting.
Why It Matters
This workaround addresses a pricing gap that affects hobbyists and small-scale developers. Claude Pro costs $20 monthly for unlimited web usage, while API access operates on pay-per-token pricing that can quickly exceed that amount for moderate usage. Someone building personal automation tools or running occasional batch processing jobs faces an awkward choice: pay for API credits they might not fully utilize, or manually copy-paste through the web interface.
The technique particularly benefits developers prototyping applications before committing to production infrastructure. Testing conversational flows, experimenting with prompt engineering, or building proof-of-concept integrations becomes more accessible when the cost barrier drops. Educational projects and open-source tools also gain a viable path forward without requiring grant funding or sponsorship to cover API expenses.
However, this creates tension within Anthropic’s business model. The company prices Pro subscriptions for individual interactive use, not programmatic access at scale. If this workaround becomes widespread, it could force pricing adjustments that ultimately harm the users it currently helps.
Getting Started
The full walkthrough appears in this video: https://www.youtube.com/watch?v=Z87M1O_Aq7E
The basic implementation requires a few components. First, provision a VPS - the smallest tier typically suffices since the server just proxies requests. Install Python 3.8 or newer, then set up the Claude Code SDK and FastAPI:
The FastAPI wrapper needs an endpoint that accepts prompts and returns responses. A minimal implementation looks like:
app = FastAPI()
client = Anthropic() # Uses ANTHROPIC_API_KEY from environment
@app.post("/chat")
async def chat(prompt: str):
message = client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=1024,
messages=[{"role": "user", "content": prompt}]
)
return {"response": message.content[0].text}
Authentication happens through the SDK’s standard credential flow. Once configured, the server runs with uvicorn main:app --host 0.0.0.0 --port 8000, creating an endpoint accessible at the VPS IP address.
Context
This approach sits in a gray area of terms of service. While not explicitly prohibited, it clearly circumvents the intended separation between Pro subscriptions and API access. Anthropic monitors usage patterns, and accounts generating API-equivalent traffic worth $200-$400 monthly risk suspension. The technique works for personal projects with modest usage, but production applications should use official API access.
Legitimate alternatives exist for cost-conscious developers. Anthropic offers API credits for researchers and educators through their academic program. Open-source models like Llama or Mistral provide free alternatives, though with different capabilities. For teams, pooling resources for shared API access often proves more economical than individual workarounds.
The broader question involves sustainable pricing for AI services. Current models assume either individual interactive use or high-volume commercial deployment, leaving a gap for intermediate use cases. As the ecosystem matures, tiered pricing structures that accommodate hobbyists and small projects may emerge, reducing the appeal of workarounds like this VPS technique.
Related Tips
Building Claude Code from Source: A Developer's Guide
This developer's guide walks through the complete process of building Claude Code from source, covering prerequisites, dependencies, compilation steps, and
Claude Code Cache Bug Breaks Session Resume
A bug in Claude Code's session management system destroys prompt cache efficiency when developers resume work by inadvertently deleting critical data through a
Claude Code Bug Breaks Cache on Billing Strings
A critical bug in Claude Code's standalone binary breaks prompt caching when conversations contain billing-related strings, causing the system to perform