AI Search API in Python.

AI Search API is a plain HTTPS + JSON API, so Python needs nothing but the standard requests library. Capture the answer a real user sees on ChatGPT, Perplexity, Copilot or Google AI and read it back as one canonical Envelope.

Authenticate with a bearer token, POST your query to /v1/search, and either block for the Envelope (sync) or take a 202 and poll the job (async). Charged only on a successful capture; 500 free credits to start.

search.py, one surface, inline Envelope
import os, requests

resp = requests.post(
    "https://api.aisearchapi.dev/v1/search",
    headers={"Authorization": f"Bearer {os.environ['AISEARCH_API_KEY']}"},
    params={"mode": "sync"},
    json={"query": "best crm for startups", "surfaces": ["chatgpt"]},
    timeout=60,
)
resp.raise_for_status()
envelope = resp.json()["children"][0]
print(envelope["answer"]["text"])

Fan out across surfaces.

Add more surfaces or regions and the call goes async: a 202 with a jobId, one child capture per (surface × region). Poll /v1/jobs/:id or attach a signed webhook.

The full submit → poll → read round-trip and a webhook receiver are in the docs.

fan_out.py, many surfaces, poll to completion
import os, time, requests

BASE = "https://api.aisearchapi.dev"
H = {"Authorization": f"Bearer {os.environ['AISEARCH_API_KEY']}"}

job = requests.post(f"{BASE}/v1/search", headers=H, json={
    "query": "best crm for startups",
    "surfaces": ["chatgpt", "perplexity", "google_ai_overview"],
    "regions": [{"country": "US"}, {"country": "GB"}],
}).json()

job_id = job["jobId"]
while True:
    j = requests.get(f"{BASE}/v1/jobs/{job_id}", headers=H).json()
    if j["job"]["status"] in ("completed", "partial", "failed", "canceled", "expired"):
        break
    time.sleep(2)

print(j["job"]["status"])

Python + AI Search API, asked precisely.

Do I need an SDK for Python?

No. The API is HTTPS + JSON, so requests (or httpx) is enough. There is no official SDK yet; these snippets are the whole integration.

How do I capture more than one surface at once?

Pass multiple values in surfaces (and multiple regions). Each (surface × region) becomes an independent child capture, so the call goes async: take the 202 jobId and poll /v1/jobs/:id, or attach a webhook.

Ship it in Python today.

Grab a key, spend 500 free credits on a real fan-out, and read the Envelope back. Charged only on success.

other languages:Node.jsGoPHPRuby