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

Environment Variables

NotPixel SDK automatically reads configuration from environment variables. This allows you to configure the SDK without changing code.

SDK Configuration

VariableTypeDefaultDescription
NOTPIXEL_BASE_URLstringhttps://api.notpixel.aiAPI base URL
NOTPIXEL_TIMEOUT_MSnumber1500Request timeout in milliseconds
NOTPIXEL_RETRIESnumber0Number of retries for failed requests
NOTPIXEL_MIN_SCOREnumber0.35Minimum relevance score for ads
NOTPIXEL_MODELstringDefault LLM model
NOTPIXEL_LOCALEstringptDefault locale for ads
NOTPIXEL_MOCKbooleanfalseEnable mock mode (1 or true)
NOTPIXEL_LOGbooleanfalseEnable debug logging (1 or true)

LLM Provider API Keys

Configure API keys for the LLM providers you want to use:

VariableProvider
OPENAI_API_KEYOpenAI 
ANTHROPIC_API_KEYAnthropic 
GOOGLE_API_KEYGoogle Gemini 
GITHUB_TOKENGitHub Models 
DEEPSEEK_API_KEYDeepSeek 
GROQ_API_KEYGroq 
MISTRAL_API_KEYMistral 
XAI_API_KEYxAI Grok 
DASHSCOPE_API_KEYAlibaba DashScope 
LLAMA_API_KEYMeta Llama 
MINIMAX_API_KEYMinimax 
NVIDIA_API_KEYNvidia Build 
PERPLEXITY_API_KEYPerplexity 
TOGETHER_API_KEYTogether AI 
OPENROUTER_API_KEYOpenRouter 
VERCEL_API_KEYVercel 
NETLIFY_API_KEYNetlify 

You only need to configure API keys for the providers you want to use. The SDK auto-detects which keys are available.

Example .env File

.env
# NotPixel Configuration NOTPIXEL_MIN_SCORE=0.35 NOTPIXEL_TIMEOUT_MS=2000 NOTPIXEL_MODEL=openai/gpt-5.2 # LLM Provider Keys (add the ones you use) OPENAI_API_KEY=sk-... ANTHROPIC_API_KEY=sk-ant-... GOOGLE_API_KEY=AI...

Development Environment

For development, enable mock mode to avoid API calls:

.env.development
NOTPIXEL_MOCK=1 NOTPIXEL_LOG=1

Overriding at Runtime

Environment variables can be overridden when initializing the SDK:

import Ads from 'notpixel'; const ads = new Ads({ publisherId: 'pub_10565', model: 'anthropic/claude-opus-4.5', input: 'Draft a launch checklist for a mobile app release.', // These override environment variables timeoutMs: 3000, minContextScore: 0.5, });

Priority Order

Configuration is applied in this order (later overrides earlier):

  1. Default values (built into SDK)
  2. Environment variables
  3. Constructor options
// NOTPIXEL_TIMEOUT_MS=2000 in .env const ads = new Ads({ publisherId: 'pub_10565', model: 'openai/gpt-5.2', input: 'Compare observability tools for a backend team.', timeoutMs: 3000, // This wins - 3000ms used });

Next.js Configuration

For Next.js projects, add variables to your .env.local:

.env.local
NOTPIXEL_MIN_SCORE=0.35 OPENAI_API_KEY=sk-...

Never commit API keys to version control. Add .env.local to your .gitignore.

Vercel Deployment

When deploying to Vercel, add environment variables in your project settings:

  1. Go to your project in Vercel
  2. Navigate to SettingsEnvironment Variables
  3. Add each variable with its value
  4. Select which environments need the variable (Production, Preview, Development)