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
| Variable | Type | Default | Description |
|---|---|---|---|
NOTPIXEL_BASE_URL | string | https://api.notpixel.ai | API base URL |
NOTPIXEL_TIMEOUT_MS | number | 1500 | Ad HTTP request timeout in milliseconds |
NOTPIXEL_RETRIES | number | 0 | Retries for failed NotPixel requests |
NOTPIXEL_MIN_SCORE | number | 0 | Optional lexical post-filter, disabled by default |
NOTPIXEL_MODEL | string | — | Default LLM model |
NOTPIXEL_LOCALE | string | pt | Default locale for ads |
NOTPIXEL_LOG | boolean | false | Opt into inference logs (1) |
LLM Provider API Keys
Configure API keys for the LLM providers you want to use:
| Variable | Provider |
|---|---|
OPENAI_API_KEY | OpenAI |
ANTHROPIC_API_KEY | Anthropic |
GOOGLE_API_KEY | Google Gemini |
GITHUB_TOKEN | GitHub Models |
DEEPSEEK_API_KEY | DeepSeek |
GROQ_API_KEY | Groq |
MISTRAL_API_KEY | Mistral |
XAI_API_KEY | xAI Grok |
DASHSCOPE_API_KEY | Alibaba DashScope |
LLAMA_API_KEY | Meta Llama |
MINIMAX_API_KEY | Minimax |
NVIDIA_API_KEY | Nvidia Build |
PERPLEXITY_API_KEY | Perplexity |
TOGETHER_API_KEY | Together AI |
OPENROUTER_API_KEY | OpenRouter |
VERCEL_API_KEY | Vercel |
NETLIFY_API_KEY | Netlify |
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
# 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):
- Default values (built into SDK)
- Environment variables
- 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:
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:
- Go to your project in Vercel
- Navigate to Settings → Environment Variables
- Add each variable with its value
- Select which environments need the variable (Production, Preview, Development)