Unofficial OpenAI Ads SDK
Unofficial, not affiliated with OpenAI. Created and maintained by Ilya Baklanov.
TypeScript and Python SDKs for advertisers using the OpenAI Ads Advertiser API. Handwritten clients, typed models, pagination, retries, uploads, insights, and CPM/CPC lifecycle coverage.
Official API docs: developers.openai.com/ads/api-overview
npm install unofficial-openai-ads-sdk
pip install unofficial-openai-ads-sdk
import { OpenAIAds } from "unofficial-openai-ads-sdk";
const ads = new OpenAIAds({ apiKey: process.env.OPENAI_ADS_API_KEY });
const campaign = await ads.campaigns.create({
name: "Spring launch",
status: "paused",
budget: { lifetime_spend_limit_micros: 100_000_000 },
targeting: { locations: { countries: ["US"] } },
bidding_type: "clicks",
});
console.log(campaign.id);
| What it does | What it does not do |
|---|---|
| Campaigns, ad groups, ads, uploads, ad account, and insights. | It is not an official OpenAI package or endorsed integration. |
| Typed TypeScript and Python clients with strict request validation. | It does not run in browsers with advertiser API keys. |
| Pagination, timeouts, typed errors, request IDs, and retry handling. | It does not manage pixels, Conversions API, billing, or creative policy review. |
| CPM and CPC creation paths. | It does not guarantee recently changed API behavior will stay stable. |
Python Quickstart
import os
from openai_ads import OpenAIAds
client = OpenAIAds(api_key=os.environ["OPENAI_ADS_API_KEY"])
campaign = client.campaigns.create(
name="Spring launch",
status="paused",
budget={"lifetime_spend_limit_micros": 100_000_000},
targeting={"locations": {"countries": ["US"]}},
bidding_type="clicks",
)
print(campaign.id)
Package Names
- TypeScript:
unofficial-openai-ads-sdk - Python:
unofficial-openai-ads-sdk, imported asopenai_ads
Supported API Surface
- Campaigns
- Ad groups
- Ads
- Uploads
- Ad account
- Insights
The SDK models the current public OpenAI Ads API and supports CPC creation with billing_event_type = "click" for CPC ad groups and bidding_type = "clicks" for net-new CPC campaigns.
Reliability
- Retries
408,409,429, and5xxwith exponential backoff and jitter. - Honors
Retry-After. - Does not retry mutating requests by default unless an idempotency key or explicit retry option is provided.
- Parses unknown response fields without failing, while keeping request validation strict.
Development
npm install
npm run build
npm run test
uv sync --all-extras --dev
uv run pytest
uv run ruff check .
uv run pyright
Live API integration tests are opt-in:
OPENAI_ADS_API_KEY=... npm run test -w packages/typescript -- test/live-api.test.ts
OPENAI_ADS_API_KEY=... uv run pytest python/tests/test_live_api.py
Mutating live tests must also set OPENAI_ADS_LIVE_MUTATE=1.
Metadata
Release files for unofficial-openai-ads-sdk 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| unofficial_openai_ads_sdk-0.1.1.tar.gz | 8.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| unofficial_openai_ads_sdk-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.7 kB
Release files / unofficial_openai_ads_sdk-0.1.1.tar.gz
| Download URL | unofficial_openai_ads_sdk-0.1.1.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ae0949884ea945078f1ce67e2f90f91fce1ca5dbef393339af64f51de8f2f59d
|
|
BLAKE2b-256 checksum How to use checksums |
fa91609ef2ddfecf28efea19b2560d31234f738dbe22c37e5cf2983f109e4194
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / unofficial_openai_ads_sdk-0.1.1-py3-none-any.whl
| Download URL | unofficial_openai_ads_sdk-0.1.1-py3-none-any.whl |
|---|---|
| Size | 11.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f4000cfaeaf0fda89104937904fc2af58f7f90a15f404c239b61349b422bf464
|
|
BLAKE2b-256 checksum How to use checksums |
d67bb15e8914d59827080aebca1e51228034eecca367696b8668c747ad520e70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|