AI Search API in PHP.

AI Search API is a plain JSON API, so PHP’s cURL (or Guzzle) is all you need. Capture what a real user sees on ChatGPT, Perplexity, Copilot or Google AI and read the canonical Envelope back.

Bearer-authenticate, POST to /v1/search, and either block for the Envelope (sync) or take the 202 and poll. Charged only on a successful capture; 500 free credits to start.

search.php, one surface, inline Envelope
<?php
$ch = curl_init("https://api.aisearchapi.dev/v1/search?mode=sync");
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer " . getenv("AISEARCH_API_KEY"),
    "Content-Type: application/json",
  ],
  CURLOPT_POSTFIELDS => json_encode([
    "query" => "best crm for startups",
    "surfaces" => ["chatgpt"],
  ]),
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
echo $data["children"][0]["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.

Submit then poll GET /v1/jobs/:id
<?php
// A multi-surface / multi-region POST returns 202 + ["jobId" => "..."].
// Poll until the job status is terminal:
//
//   do {
//     sleep(2);
//     $j = json_decode(file_get_contents_with_bearer(
//         "$BASE/v1/jobs/$jobId"), true);
//   } while (!in_array($j["job"]["status"],
//       ["completed", "partial", "failed", "canceled", "expired"]));
//
// Each (surface × region) is one child capture, counted once.

PHP + AI Search API, asked precisely.

Do I need a PHP SDK?

No. cURL or Guzzle over the JSON contract is the whole integration. There is no official SDK yet.

Sync or async in PHP?

A single surface + region can run sync (?mode=sync) and return the Envelope inline. Add more surfaces or regions and it goes async: poll /v1/jobs/:id or use a signed webhook.

Ship it in PHP today.

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

other languages:PythonNode.jsGoRuby