OpenAI
Access OpenAI models through NotPixel. OpenAI offers the most widely-used LLM models including GPT-4o.
Setup
1. Get API Key
- Go to OpenAI Platform
- Create an account or sign in
- Navigate to API Keys
- 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
Recommended Models
| Model | Context | Best For | Input Cost | Output Cost |
|---|---|---|---|---|
openai/gpt-5.2 | 128K | Latest flagship model | $2.50/M | $10/M |
openai/gpt-5.2-mini | 128K | Fast & affordable | $0.15/M | $0.60/M |
openai/gpt-4-turbo | 128K | Advanced reasoning | $10/M | $30/M |
Reasoning Models (o1 Series)
| Model | Context | Best For | Input Cost | Output Cost |
|---|---|---|---|---|
openai/o1 | 200K | Complex reasoning | $15/M | $60/M |
openai/o1-mini | 128K | Faster reasoning | $1.10/M | $4.40/M |
openai/o1-preview | 128K | Preview version | $15/M | $60/M |
Legacy Models
| Model | Context | Best For | Input Cost | Output Cost |
|---|---|---|---|---|
openai/gpt-4 | 8K | Original GPT-4 | $30/M | $60/M |
openai/gpt-3.5-turbo | 16K | Budget 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 Case | Recommended Model |
|---|---|
| General Q&A | openai/gpt-5.2-mini |
| Complex analysis | openai/gpt-5.2 |
| Code generation | openai/gpt-5.2 |
| Math & logic | openai/o1 |
| High volume / cost-sensitive | openai/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
| Variable | Description |
|---|---|
OPENAI_API_KEY | Your OpenAI API key |
Never commit your API key to version control. Always use environment variables.