Skip to Content
NotPixel SDK v2.0.0 — Privacy-first defaults, public tracking metadata, and stronger SDK/API coverage.
Getting StartedQuick Start

Quick Start

Get up and running with NotPixel in under 5 minutes.

Basic Usage

import Ads from 'notpixel'; const ads = new Ads({ publisherId: 'pub_10565', model: 'openai/gpt-5.2', input: 'Summarize this support conversation and suggest useful developer products.', }); const response = await ads.offer(); console.log(response.text); // Output: // To optimize SQL queries, consider these strategies... // // --- // Sponsored: DataDog Monitoring // Real-time SQL insights and performance tracking. // Learn more: https://datadoghq.com

That’s it. The SDK:

  1. Routes your input to the specified LLM provider
  2. Fetches a relevant ad in parallel
  3. Returns the LLM response with the ad seamlessly integrated

Configuration

Pass everything in the constructor:

OptionRequiredDescription
publisherIdYesYour publisher ID
modelYesLLM model in provider/model format
inputYesUser’s input text
cacheNoEnable caching (default: false)
localeNoAd locale: 'pt' or 'en' (default: 'pt')
const ads = new Ads({ publisherId: 'pub_10565', model: 'openai/gpt-5.2', input: 'Recommend tools for improving a cloud onboarding experience.', cache: true, locale: 'en', });

Multiple Requests

For multiple requests, you can override the input per call:

const ads = new Ads({ publisherId: 'pub_10565', model: 'openai/gpt-5.2', input: 'Review this developer workflow and suggest relevant tools.', }); // First request const r1 = await ads.offer({ input: 'What is Docker?' }); // Second request const r2 = await ads.offer({ input: 'How do I deploy to AWS?' });

Just Fetch an Ad

If you only need the ad (not the LLM response):

const ads = new Ads({ publisherId: 'pub_10565', model: 'openai/gpt-5.2', input: 'Recommend cloud tooling for an engineering team.', }); const ad = await ads.getAd(); if (ad) { console.log(ad.headline); // "AWS Cloud Services" console.log(ad.body); // "Scale your infrastructure..." console.log(ad.cta.url); // "https://aws.amazon.com" }

Environment Variables

API keys are read from environment automatically:

.env
OPENAI_API_KEY=sk-... # or ANTHROPIC_API_KEY=sk-ant-... # or GOOGLE_API_KEY=AI...

See Environment Variables for all available options.

Tracking (Optional)

For client-side tracking, use the Browser Tracking library.

Next Steps