Skip to Content
NotPixel SDK v1.0.1 — Now with caching, hooks, and browser tracking!
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_xxx', model: 'openai/gpt-5.2', input: 'How do I optimize SQL queries for better performance?', }); 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_xxx', model: 'openai/gpt-5.2', input: 'Explain microservices architecture', cache: true, locale: 'en', });

Multiple Requests

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

const ads = new Ads({ publisherId: 'pub_xxx', model: 'openai/gpt-5.2', }); // 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_xxx', input: 'cloud hosting recommendations', }); 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