Skip to Content
Get StartedEnvironment Variables
Get Started

Environment Variables

The JavaScript and Python SDKs read configuration from the process environment. Your framework, runtime or application must load .env files; the SDKs do not load those files themselves.

SDK Configuration

VariableTypeDefaultDescription
NOTPIXEL_BASE_URLstringhttps://api.notpixel.aiAPI base URL
NOTPIXEL_TIMEOUT_MSnumber1500Ad HTTP request timeout in milliseconds
NOTPIXEL_RETRIESnumber0Retries for failed NotPixel requests
NOTPIXEL_MIN_SCOREnumber0Optional lexical post-filter, disabled by default
NOTPIXEL_MODELstring—Default LLM model
NOTPIXEL_LOCALEstringptDefault locale for ads
NOTPIXEL_LOGbooleanfalseOpt into inference logs (1)

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 reads the key required by the provider prefix in your configured model. LM Studio does not require a key. Google also accepts GEMINI_API_KEY.

Example .env File

.env
# NotPixel Configuration NOTPIXEL_MIN_SCORE=0 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

Use test mode with getAd() or get_ad() to preview real ads without calling an LLM.

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

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

Python inference timeout

Python has a separate llm_timeout_ms constructor option, defaulting to 60,000 ms. NOTPIXEL_TIMEOUT_MS controls NotPixel ad/event requests, not LLM inference. Python does not automatically retry inference calls or replay partial streams.

from notpixel import AsyncAds ads = AsyncAds(publisher_id="YOUR_PUBLISHER_ID", timeout_ms=1500, llm_timeout_ms=60000)

Next.js Configuration

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

.env.local
NOTPIXEL_MIN_SCORE=0 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 Settings → Environment Variables
  3. Add each variable with its value
  4. Select which environments need the variable (Production, Preview, Development)
Last updated on
Was this helpful?