{"_id":"@agentads/sdk","_rev":"6-b84ba7e7c0b1398048ee5642765ff569","name":"@agentads/sdk","dist-tags":{"latest":"0.5.0"},"versions":{"0.3.0":{"name":"@agentads/sdk","version":"0.3.0","keywords":["ai","ads","monetization","vercel-ai-sdk","langchain","openai"],"license":"MIT","_id":"@agentads/sdk@0.3.0","maintainers":[{"name":"alprina","email":"malte@joshwagenbach.com"}],"homepage":"https://github.com/0xShortx/agentads-sdk#readme","bugs":{"url":"https://github.com/0xShortx/agentads-sdk/issues"},"dist":{"shasum":"61600f16183105ee8832b3afe7cec459487e658c","tarball":"https://registry.npmjs.org/@agentads/sdk/-/sdk-0.3.0.tgz","fileCount":6,"integrity":"sha512-GNpqk4BXget8OI1WzssYKH5YbVimBwwv+5DefcHBVW2m6/DLkDLpIuRjNl4B03iNScDpYPEGptn/5z1XVnwRQA==","signatures":[{"sig":"MEQCIC7ox4PJVbuT37PB3WwB/zERa7ws3iH3DUSw/ILeaJ+ZAiBd+ue8Sk5tVFdZ8meS33Zz1dOoTdb7t01Y/CvkDd3FwA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":33228},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"741b8162c2726ebb0c68458430aefe8c3af022d7","scripts":{"dev":"tsup --watch","build":"tsup","prepublishOnly":"npm run build"},"_npmUser":{"name":"alprina","email":"malte@joshwagenbach.com"},"repository":{"url":"git+https://github.com/0xShortx/agentads-sdk.git","type":"git"},"_npmVersion":"10.8.2","description":"Monetize your AI app — add revenue to AI responses in 5 lines","directories":{},"_nodeVersion":"20.19.5","_hasShrinkwrap":false,"devDependencies":{"ai":"^4.0.0","tsup":"^8.0.0","typescript":"^5.6.0","@ai-sdk/provider":"^1.0.0"},"peerDependencies":{"ai":">=3.0.0","react":">=17"},"peerDependenciesMeta":{"ai":{"optional":true},"react":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.3.0_1772312320642_0.7510152959068741","host":"s3://npm-registry-packages-npm-production"}},"0.1.0":{"name":"@agentads/sdk","version":"0.1.0","keywords":["ai","ads","monetization","llm","agentads"],"license":"MIT","_id":"@agentads/sdk@0.1.0","maintainers":[{"name":"alprina","email":"malte@joshwagenbach.com"}],"homepage":"https://github.com/0xShortx/agentads#readme","bugs":{"url":"https://github.com/0xShortx/agentads/issues"},"dist":{"shasum":"2b2986fa3cc9fc45cb53aecaf57ec83d80cb43ea","tarball":"https://registry.npmjs.org/@agentads/sdk/-/sdk-0.1.0.tgz","fileCount":9,"integrity":"sha512-PAamTIDPapMi/Ogp6x+rutr3SPx5gWfZRHRuMwxQf4jY04CpQsiwl0J2IKsZ28GRy49DYXEulO/v/yO8IlWZQA==","signatures":[{"sig":"MEUCIQCb7jHURgvFMOsoxmE97+uU23tGmY7rh9Z7s6qsaxXwnwIgAJgquivRIAXU6Xeoq8zX655kYyKITFzllr+PQXMoGhY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18512},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./react":{"types":"./dist/react.d.ts","import":"./dist/react.mjs","require":"./dist/react.js"}},"gitHead":"3ea658429d87b19753185db5747b9f465c061dbc","scripts":{"dev":"tsup --watch","build":"tsup"},"_npmUser":{"name":"alprina","email":"malte@joshwagenbach.com"},"repository":{"url":"git+https://github.com/0xShortx/agentads.git","type":"git"},"_npmVersion":"10.8.2","description":"AgentAds SDK — monetize your AI app with one line","directories":{},"_nodeVersion":"20.19.5","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.0.0","@types/react":"^18"},"peerDependencies":{"react":">=17"},"peerDependenciesMeta":{"react":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.1.0_1772365036375_0.31661360914659586","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@agentads/sdk","version":"0.1.1","keywords":["ai","ads","monetization","llm","agentads"],"license":"MIT","_id":"@agentads/sdk@0.1.1","maintainers":[{"name":"alprina","email":"malte@joshwagenbach.com"}],"homepage":"https://github.com/0xShortx/agentads#readme","bugs":{"url":"https://github.com/0xShortx/agentads/issues"},"dist":{"shasum":"f39e517d2456c900c7aa6c099c0b97a3e9b505b3","tarball":"https://registry.npmjs.org/@agentads/sdk/-/sdk-0.1.1.tgz","fileCount":10,"integrity":"sha512-saW5uha7pVtRMZaBfoZ031yhrLwWL3UXNHDeZXTcDfBTlkcgAbBfnFOabyYdKKVYbAyOAawe03K4gfUQr5oRbw==","signatures":[{"sig":"MEUCIQCvphURN/UjAvjWEd8r+gWzn3BFzF5bgaQfCGMyKhhGKwIgePI1QCo1L/CnKn7qqiZy5Pz1n8nvA+yOrZqbYohiDyU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20977},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./react":{"types":"./dist/react.d.ts","import":"./dist/react.mjs","require":"./dist/react.js"}},"gitHead":"5e8cf5010c81608adcdaed5046d5436a2dae5f49","scripts":{"dev":"tsup --watch","build":"tsup"},"_npmUser":{"name":"alprina","email":"malte@joshwagenbach.com"},"repository":{"url":"git+https://github.com/0xShortx/agentads.git","type":"git"},"_npmVersion":"10.8.2","description":"AgentAds SDK — monetize your AI app with one line","directories":{},"_nodeVersion":"20.19.5","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.0.0","@types/react":"^18"},"peerDependencies":{"react":">=17"},"peerDependenciesMeta":{"react":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.1.1_1778511336397_0.7715798765960935","host":"s3://npm-registry-packages-npm-production"}},"0.4.0":{"name":"@agentads/sdk","version":"0.4.0","keywords":["ai","ads","monetization","llm","agentads"],"license":"MIT","_id":"@agentads/sdk@0.4.0","maintainers":[{"name":"alprina","email":"malte@joshwagenbach.com"}],"homepage":"https://github.com/0xShortx/agentads#readme","bugs":{"url":"https://github.com/0xShortx/agentads/issues"},"dist":{"shasum":"d9de00ee06cccebb9d38bd02c9fa68d05817b98c","tarball":"https://registry.npmjs.org/@agentads/sdk/-/sdk-0.4.0.tgz","fileCount":10,"integrity":"sha512-Nqmpgp/lf/mNhYFi7grfgxmmgh5CCL6YrkVIEB+6pmYDcT6z6jYRPb9FP/vtcEFsidKZNpPBJ9z3BOoi+ebpjg==","signatures":[{"sig":"MEQCIGOth609kY5jifNkb6iVu+5MZWgua6hRojOEgAPmJLeGAiAJFucDFgPuRJD7mGEqqOIb3pVrDJrKHdMlEhPIsS2S4Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":38561},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./react":{"types":"./dist/react.d.ts","import":"./dist/react.mjs","require":"./dist/react.js"}},"gitHead":"649e7579cc87663b8871e210a5bf2d72e0878f89","scripts":{"dev":"tsup --watch","build":"tsup"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:271bc6de-b7d8-457f-a676-8b719d8185dc"}},"repository":{"url":"git+https://github.com/0xShortx/agentads.git","type":"git"},"_npmVersion":"12.0.2","description":"Monetize your AI app — contextual ads after AI responses, in 5 lines","directories":{},"_nodeVersion":"24.20.0","_hasShrinkwrap":false,"devDependencies":{"ai":"^4.0.0","tsup":"^8.0.0","typescript":"^5.0.0","@types/react":"^18","@ai-sdk/provider":"^1.0.0"},"peerDependencies":{"ai":">=3.0.0","react":">=17"},"peerDependenciesMeta":{"ai":{"optional":true},"react":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.4.0_1788427693751_0.06003820513828173","host":"s3://npm-registry-packages-npm-production"}},"0.4.1":{"name":"@agentads/sdk","version":"0.4.1","keywords":["ai","ads","monetization","llm","agentads"],"license":"MIT","_id":"@agentads/sdk@0.4.1","maintainers":[{"name":"alprina","email":"malte@joshwagenbach.com"}],"homepage":"https://github.com/0xShortx/agentads#readme","bugs":{"url":"https://github.com/0xShortx/agentads/issues"},"dist":{"shasum":"04b8eaeaeb84d63eb5ba6351979c7771b1995964","tarball":"https://registry.npmjs.org/@agentads/sdk/-/sdk-0.4.1.tgz","fileCount":15,"integrity":"sha512-473kt4Rll496G29pqqmsE0sK53IO1lRkdA0vRmoD1hLYiMZh29K7VDeXLfJUhWCHfIqHNPeDd4JTxfUprcUivQ==","signatures":[{"sig":"MEYCIQC3TC+22vUdKCNjTzWawUrMZDOf3DLNye7TcuZZxL/jjgIhAP70NKBnuNuewsq3erZpr9+E1PEgj5aDCbYrGTxrxSxG","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":39670},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./ai":{"types":"./dist/ai.d.ts","import":"./dist/ai.mjs","require":"./dist/ai.js"},"./react":{"types":"./dist/react.d.ts","import":"./dist/react.mjs","require":"./dist/react.js"},"./package.json":"./package.json"},"gitHead":"c64d32a0dcc55433e2c330ab83a43832a11f28f7","scripts":{"dev":"tsup --watch","build":"tsup"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:271bc6de-b7d8-457f-a676-8b719d8185dc"}},"repository":{"url":"git+https://github.com/0xShortx/agentads.git","type":"git"},"_npmVersion":"12.0.2","description":"Monetize your AI app — contextual ads after AI responses, in 5 lines","directories":{},"_nodeVersion":"24.20.0","_hasShrinkwrap":false,"devDependencies":{"ai":"^4.0.0","tsup":"^8.0.0","typescript":"^5.0.0","@types/react":"^18","@ai-sdk/provider":"^1.0.0"},"peerDependencies":{"ai":">=3.0.0","react":">=17"},"peerDependenciesMeta":{"ai":{"optional":true},"react":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/sdk_0.4.1_1788427901943_0.03501766204017498","host":"s3://npm-registry-packages-npm-production"}},"0.5.0":{"name":"@agentads/sdk","version":"0.5.0","description":"Monetize your AI app — contextual ads after AI responses, in 5 lines","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./ai":{"types":"./dist/ai.d.ts","import":"./dist/ai.mjs","require":"./dist/ai.js"},"./react":{"types":"./dist/react.d.ts","import":"./dist/react.mjs","require":"./dist/react.js"},"./package.json":"./package.json"},"scripts":{"build":"tsup","dev":"tsup --watch"},"peerDependencies":{"ai":">=3.0.0","react":">=17"},"peerDependenciesMeta":{"ai":{"optional":true},"react":{"optional":true}},"devDependencies":{"@ai-sdk/provider":"^1.0.0","ai":"^4.0.0","tsup":"^8.0.0","typescript":"^5.0.0","@types/react":"^18"},"keywords":["ai","ads","monetization","llm","agentads"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/0xShortx/agentads.git"},"engines":{"node":">=18"},"gitHead":"5b36def182f2671adbddfb836df2f046758b1677","_id":"@agentads/sdk@0.5.0","bugs":{"url":"https://github.com/0xShortx/agentads/issues"},"homepage":"https://github.com/0xShortx/agentads#readme","_nodeVersion":"24.19.0","_npmVersion":"12.0.2","dist":{"integrity":"sha512-XMds7e9rCW2YAcdT51goOanyqzqF3gFdcPURwwiLd++UGaw7sbwirCRGFOMsbXkRVipAyznLfuCSgOQ/yvi/Wg==","shasum":"cb7e3f0784ed4c31ba6a3c274169a05df74ec019","tarball":"https://registry.npmjs.org/@agentads/sdk/-/sdk-0.5.0.tgz","fileCount":15,"unpackedSize":43431,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDeCrrLj2ElU0IN4T2xhNUXa91J8DrOb/ERj8rsjnnutAIhANdfdVWwCI8lTLqPplpg5TdunUsTpEd4SyGq0Wrg66EY"}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:271bc6de-b7d8-457f-a676-8b719d8185dc"}},"directories":{},"maintainers":[{"name":"alprina","email":"malte@joshwagenbach.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.5.0_1788432277664_0.41879562209424437"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-28T20:58:40.538Z","modified":"2026-09-03T10:44:38.019Z","0.3.0":"2026-02-28T20:58:40.799Z","0.1.0":"2026-03-01T11:37:16.513Z","0.1.1":"2026-05-11T14:55:36.553Z","0.4.0":"2026-09-03T09:28:13.932Z","0.4.1":"2026-09-03T09:31:42.080Z","0.5.0":"2026-09-03T10:44:37.815Z"},"bugs":{"url":"https://github.com/0xShortx/agentads/issues"},"license":"MIT","homepage":"https://github.com/0xShortx/agentads#readme","keywords":["ai","ads","monetization","llm","agentads"],"repository":{"type":"git","url":"git+https://github.com/0xShortx/agentads.git"},"description":"Monetize your AI app — contextual ads after AI responses, in 5 lines","maintainers":[{"name":"alprina","email":"malte@joshwagenbach.com"}],"readme":"# @agentads/sdk\n\nMonetize your AI app. Append a single contextual ad after each LLM response, keep 70% of every ad dollar.\n\n```bash\nnpm install @agentads/sdk\n```\n\n## Quickstart\n\nGet an API key at [app.tryagentads.com](https://app.tryagentads.com/auth/signup?type=publisher), then:\n\n```ts\nimport { fetchAd } from '@agentads/sdk'\n\nconst ad = await fetchAd({\n  publisherApiKey: process.env.AGENTADS_API_KEY!,\n  query: userMessage,\n  response: assistantText,\n})\n\nif (ad) {\n  // append `ad.headline`, `ad.description`, `ad.ctaText`, `ad.clickUrl`\n}\n```\n\nThe auction has a hard **50 ms timeout**. If no ad wins, `fetchAd` returns `null` — safe to ignore.\n\n## Wrap any AI SDK\n\nUse `withAgentAds()` to wrap a model object (Vercel AI SDK, OpenAI SDK, anything with a `doGenerate` or `doStream` method). The wrapped model auto-appends an ad to each response.\n\n```ts\nimport { withAgentAds } from '@agentads/sdk'\nimport { openai } from '@ai-sdk/openai'\n\nconst model = withAgentAds(openai('gpt-4o'), {\n  publisherApiKey: process.env.AGENTADS_API_KEY!,\n})\n\n// use `model` exactly like before — ads attach automatically\n```\n\n## React component\n\n```tsx\nimport { AgentAd } from '@agentads/sdk/react'\n\n<AgentAd\n  publisherApiKey={process.env.NEXT_PUBLIC_AGENTADS_KEY!}\n  query={userMessage}\n  response={assistantText}\n/>\n```\n\nRenders nothing on no-fill. No layout shift.\n\n## API\n\n### `fetchAd(options)` → `Promise<Ad | null>`\n\n| Option | Type | Default |\n| --- | --- | --- |\n| `publisherApiKey` | `string` | — (required) |\n| `query` | `string` | — |\n| `response` | `string` | — |\n| `apiUrl` | `string` | `https://api.tryagentads.com` |\n| `timeout` | `number` (ms) | `50` |\n\nReturns:\n\n```ts\ntype Ad = {\n  id: string\n  headline: string\n  description: string\n  ctaText: string\n  destinationUrl: string\n  clickUrl: string  // tracked click URL\n}\n```\n\nReturns `null` on no-fill, timeout, invalid key, or network error. The SDK never throws.\n\n### `withAgentAds(model, { publisherApiKey, apiUrl? })`\n\nProxies the model. Intercepts `doGenerate` and `doStream` results and appends a `Sponsored:` block to `.text` if an ad wins the auction.\n\n## Bundle size\n\n- `@agentads/sdk` — 1.7 KB raw / ~800 B gzipped\n- `@agentads/sdk/react` — 3.7 KB raw / ~1.3 KB gzipped\n\nReact is an optional peer dep. The main entrypoint has zero runtime deps.\n\n## License\n\nMIT — built by [AgentAds](https://tryagentads.com).\n","readmeFilename":"README.md"}