Toggle Theme
Feedback
Help Center

For Vibecoders

1

Agent prompt

The fastest way to add Zerocost to your project — paste this prompt into Cursor, Bolt, Windsurf, or any AI coding agent and let it handle the rest.

Copy this entire block and paste it into your agent's chat window.

Prompt for Agent
Set up the Zerocost SDK in this project.

1. Run in terminal:
   npx @zerocost/sdk
   This installs the package and auto-creates a Zerocost config file.

2. Verify whether this app uses TypeScript or JavaScript (e.g., Next.js/Vite projects can be either). Decide which config file to use:
   - TypeScript: src/zerocost.ts
   - JavaScript: src/zerocost.js (or zerocost.js if no src directory)

3. Replace the config file contents using the selected mode (TypeScript):
   - File: src/zerocost.ts

import { ZerocostSDK } from '@zerocost/sdk';

// This is your src/zerocost.ts file
export const zc = new ZerocostSDK({
  appId: "your_app_id",
  apiKey: "zc_live_YOUR_KEY_HERE",
  appName: "My App",
  debug: true,
  llm: {
    llmPath: "/api" // Enter which page on your app has the most interaction for precision
  },
  consent: {
    showSettingsButton: true, // Recommended: show a floating "Privacy Settings" button
  },
  // Optional: mirror the roles you save in Ad Display
  ads: {
    roleTargeting: {
      enabled: true,
      allowedRoles: ["free", "basic"]
    }
  }
});

// Optional: role-based ad visibility
zc.identify("user_123", {
  role: "free"
});

zc.init().catch(console.error);

4. Import this file in the project entry point (e.g. main.ts, index.ts, layout.tsx, or equivalent):
   import "./zerocost";

5. Ask the user if they want to:
   - Verify if the credentials are correct with the user like the App Name, etc.
   - Provide the appId and API key if they were not provided to you. If either is missing, use https://zerocost.app/ to help them create an account and get their credentials there.
   - Setup Zerocost's built-in consent popup.
   - Direct ads only to specific plans/roles (e.g., only 'free' users).
   - Enable LLM-data selling (anonymized) - if yes, ask what route their AI chatbot lives on.
   Once you get these inputs, update the zc config accordingly.

6. Confirm the setup with the user before finishing.
2

How it works

Step 1

Authentication

The agent handles App ID and API Key setup via secure variables.

Step 2

Automation

Runs CLI commands to auto-generate the SDK configuration.

Step 3

Configuration

Sets up targeting, ads, and consent options in one pass.

Step 4

Integration

Wires the SDK into your entry layout automatically.

3

Key lookup

Grab your keys from the Dashboard → Integration tab.

PropertyExample
App IDabc123
API Keyzc_live_...
4

Update SDK

Run the following to pull the latest SDK features.

Terminal
npm install @zerocost/sdk@latest