# ChargeMyAI > Add AI to any web page with one script tag. No API key, no backend, no billing code. Your users > pay for cloud replies from their own ChargeMyAI balance (topped up by UPI in rupees), replies the > browser can write itself are free, and the site owner earns a share of what users spend in their app (30% for the first 50 founding apps for 12 months, 20% standard). ## Add it (this is the whole integration) ```html ``` - Works in plain HTML, React, Vue, Svelte, Next.js client components. Load the script once (in index.html or the root layout), then call `window.charge.ai.chat()` from any click handler. - Call it from the browser only. There is no server SDK and nothing to put in environment variables. - Do NOT add an API key, a secret, a proxy route or a payments integration. ChargeMyAI shows its own sign-in and UPI top-up sheets when a user needs them, then sends the message. ## API `charge.ai.chat(input, options?)` returns `Promise`. - `input`: a string, or an array of `{ role: 'system' | 'user' | 'assistant', content: string }`. - `options.lang`: two-letter language of the reply, e.g. `'hi'`, `'ta'`, `'en'`. - `options.tier`: `'standard'` (₹0.10 a reply, default) or `'premium'` (₹0.25, larger model, cloud only). - `options.mode`: `'auto'` (default: device first, cloud if needed), `'device'` or `'cloud'`. - `options.stream: true` returns an async iterable of text chunks with a `.result` promise: `for await (const part of charge.ai.chat(q, { stream: true })) out.textContent += part;` - `options.onStage(stage, status, detail)`: progress for a loading UI. Stages: check, device, gate, cloud, charge. `Reply`: `{ text, route: 'device' | 'cloud', model, region: 'in' | 'abroad' | 'device', costPaise, latencyMs }`. Money is integer paise (100 paise = ₹1). Other calls: `charge.signIn()`, `charge.signOut()`, `charge.signedIn`, `await charge.balance()` (paise or null), `charge.topUp()`, `charge.account()` (opens the user's account in a new tab), `charge.configure({ lang })` for the sheets' language ('en', 'hi', 'ta'). ## Errors Calls reject with `charge.ChargeError` (`.code`, `.message`). Show `.message` to the user; it is already written for them. Codes worth handling: - `cancelled`: the user closed a sheet. Do nothing. - `daily_cap`, `paused`: the user's own limits for this app. ChargeMyAI already offered their account. - `popup_blocked`: the browser or a preview frame blocked the sign-in window. In a builder preview (Lovable, Bolt, v0, StackBlitz), open the app in its own tab. - `device_unavailable`: `mode: 'device'` was asked for and no on-device model can answer. - `upstream_unavailable`: no model answered; the user was not charged. ## Rules for the code you write - One `