Environment Variables
NotPixel SDK automatically reads configuration from environment variables. This allows you to configure the SDK without changing code.
SDK Configuration
| Variable | Type | Default | Description |
|---|---|---|---|
NOTPIXEL_BASE_URL | string | https://api.notpixel.ai | API base URL |
NOTPIXEL_TIMEOUT_MS | number | 1500 | Request timeout in milliseconds |
NOTPIXEL_RETRIES | number | 0 | Number of retries for failed requests |
NOTPIXEL_MIN_SCORE | number | 0.35 | Minimum relevance score for ads |
NOTPIXEL_MODEL | string | — | Default LLM model |
NOTPIXEL_LOCALE | string | pt | Default locale for ads |
NOTPIXEL_MOCK | boolean | false | Enable mock mode (1 or true) |
NOTPIXEL_LOG | boolean | false | Enable debug logging (1 or true) |
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 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=1Overriding at Runtime
Environment variables can be overridden when initializing the SDK:
import Ads from 'notpixel';
const ads = new Ads({
publisherId: 'pub-xxx',
// These override environment variables
timeout: 3000,
minScore: 0.5,
model: 'anthropic/claude-opus-4.5',
});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-xxx',
timeout: 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:
- 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)