Skip to main content
Vibra Code supports three AI providers for code generation: Claude (default), Cursor, and Gemini. Each provider has different API key requirements and a different billing model. Switching providers is a single environment variable change on the backend.

How provider selection works

The active provider is controlled by the AGENT_TYPE environment variable in vibracode-backend/.env.local. The value is read at server startup and determines which agent runs inside each E2B sandbox.
# In vibracode-backend/.env.local
AGENT_TYPE=claude   # or: cursor, gemini
The selected provider is also stored per-user in the agentType field of the users table in Convex, which drives the billing mode for that user’s sessions.

Provider options

Claude uses Anthropic’s Claude Agent SDK to generate code. This is the recommended provider and the default for all new installations.Billing mode: credits — usage is tracked in USD with a 2× multiplier applied to actual API costs. Users see a credit balance that depletes as they build.Required environment variables:
AGENT_TYPE=claude

# Primary API key for Claude Agent SDK
ANTHROPIC_API_KEY=

# API key used inside E2B sandboxes (can be the same key)
ANTHROPIC_SANDBOX_API_KEY=

# Base URL — override to use a proxy (default: https://api.anthropic.com)
ANTHROPIC_BASE_URL=https://api.anthropic.com
ANTHROPIC_SANDBOX_API_KEY is injected into the E2B sandbox so the agent running inside the sandbox can make its own API calls. It can be identical to ANTHROPIC_API_KEY.

Billing mode differences

The two billing modes are stored in the billingMode field of the users table in Convex.
ModeValueHow usage is trackedUsed by
Token modetokensFixed message count per plan periodCursor agent
Credit modecreditsUSD credits consumed per session (2× multiplier)Claude and Gemini agents
In token mode, the messagesRemaining and messagesUsed fields on each user record track consumption. Allowances reset via lastMessageReset. In credit mode, the creditsUSD field holds the user’s available credit balance. Each session’s actual API cost (tracked in totalCostUSD on the session) is deducted with a 2× multiplier. The realCostUSD and profitUSD fields on user records are used for internal tracking only.
Payments and subscriptions are entirely optional for self-hosted deployments. You can run Vibra Code without Stripe or RevenueCat by simply not setting those keys.

Using OpenRouter as a proxy

If you want to route Claude API calls through OpenRouter instead of calling Anthropic directly — for example, to access multiple models or manage billing in one place — set the following:
# Set AGENT_TYPE to claude, then point the base URL at OpenRouter
AGENT_TYPE=claude
ANTHROPIC_BASE_URL=https://openrouter.ai/api/v1
OPENROUTER_API_KEY=

# Use your OpenRouter key as the Anthropic API key
ANTHROPIC_API_KEY=<your-openrouter-key>
ANTHROPIC_SANDBOX_API_KEY=<your-openrouter-key>
OpenRouter is also available as a standalone optional key for additional LLM routing use cases within the backend.

Switching providers at runtime

To switch the active provider without restarting:
  1. Update AGENT_TYPE in .env.local
  2. Restart the Next.js server (npm run dev or npm run start)
  3. New sessions will use the new provider; existing sessions that are still RUNNING continue with the original provider
The provider can also be controlled via the globalConfig table in Convex for admin-level overrides without a server restart.

Build docs developers (and LLMs) love