How provider selection works
The active provider is controlled by theAGENT_TYPE environment variable in vibracode-backend/.env.local. The value is read at server startup and determines which agent runs inside each E2B sandbox.
agentType field of the users table in Convex, which drives the billing mode for that user’s sessions.
Provider options
- Claude (default)
- Cursor
- Gemini
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: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 thebillingMode field of the users table in Convex.
| Mode | Value | How usage is tracked | Used by |
|---|---|---|---|
| Token mode | tokens | Fixed message count per plan period | Cursor agent |
| Credit mode | credits | USD credits consumed per session (2× multiplier) | Claude and Gemini agents |
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:Switching providers at runtime
To switch the active provider without restarting:- Update
AGENT_TYPEin.env.local - Restart the Next.js server (
npm run devornpm run start) - New sessions will use the new provider; existing sessions that are still
RUNNINGcontinue with the original provider
globalConfig table in Convex for admin-level overrides without a server restart.