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.
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:
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. 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:
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.