Unofficial Python SDK for the OpenAI Ads Advertiser API.
Project description
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 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file unofficial_openai_ads_sdk-0.1.0.tar.gz.
File metadata
- Download URL: unofficial_openai_ads_sdk-0.1.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
067f0b1958589a039b573dbe3e3e769a56c101a08cc68b50a18c247711934780
|
|
| MD5 |
a7f7271c3f692610586b718e0da3c8bb
|
|
| BLAKE2b-256 |
e9665b72e591e7f6884f51bef36f0f6be53e1d2dabf3b512a3dea4881f0f4b27
|
File details
Details for the file unofficial_openai_ads_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: unofficial_openai_ads_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using 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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
445d8461d4f61fce010f20487ed89eb73402d8dc472f00bf9dece207853be42c
|
|
| MD5 |
92dac94c7ee9976555425ff52efd2b6f
|
|
| BLAKE2b-256 |
ea4ac51251952a6638c300b080d86aeaf0f1bf72809a2dc917345455f11d8149
|