Skip to Content
NotPixel SDK v1.0.1 — Now with caching, hooks, and browser tracking!

OpenAI

Access OpenAI models through NotPixel. OpenAI offers the most widely-used LLM models including GPT-4o.

Setup

1. Get API Key

  1. Go to OpenAI Platform 
  2. Create an account or sign in
  3. Navigate to API Keys
  4. Create a new secret key

2. Configure Environment

.env
OPENAI_API_KEY=sk-...

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);

Available Models

ModelContextBest ForInput CostOutput Cost
openai/gpt-5.2128KLatest flagship model$2.50/M$10/M
openai/gpt-5.2-mini128KFast & affordable$0.15/M$0.60/M
openai/gpt-4-turbo128KAdvanced reasoning$10/M$30/M

Reasoning Models (o1 Series)

ModelContextBest ForInput CostOutput Cost
openai/o1200KComplex reasoning$15/M$60/M
openai/o1-mini128KFaster reasoning$1.10/M$4.40/M
openai/o1-preview128KPreview version$15/M$60/M

Legacy Models

ModelContextBest ForInput CostOutput Cost
openai/gpt-48KOriginal GPT-4$30/M$60/M
openai/gpt-3.5-turbo16KBudget option$0.50/M$1.50/M

Prices are per million tokens as of December 2024. Check OpenAI Pricing  for current rates.

Model Selection Guide

// Best quality for complex tasks model: 'openai/gpt-5.2' // Fast and cost-effective for most uses model: 'openai/gpt-5.2-mini' // For tasks requiring deep reasoning model: 'openai/o1'

When to Use Each Model

Use CaseRecommended Model
General Q&Aopenai/gpt-5.2-mini
Complex analysisopenai/gpt-5.2
Code generationopenai/gpt-5.2
Math & logicopenai/o1
High volume / cost-sensitiveopenai/gpt-5.2-mini

Complete Example

import Ads from 'notpixel'; const ads = new Ads({ publisherId: 'pub_xxx', model: 'openai/gpt-5.2', cache: true, hooks: { onAdFetched: (e) => console.log(`Ad: ${e.ad.headline} (${e.latencyMs}ms)`), }, }); async function handleUserQuery(query: string) { const response = await ads.offer({ input: query }); console.log(response.text); } handleUserQuery('What database should I use for analytics?');

Environment Variable

VariableDescription
OPENAI_API_KEYYour OpenAI API key

Never commit your API key to version control. Always use environment variables.