serpkite 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -105,7 +105,10 @@ interface paths {
105
105
  };
106
106
  get?: never;
107
107
  put?: never;
108
- /** Google Images */
108
+ /**
109
+ * Google Images
110
+ * @description One page is a block of up to 100 images for 1 credit; page 2 starts at position 101. `num` returns only the first `num` images of the page (same credit). A page past the last one returns empty `results`, free.
111
+ */
109
112
  post: operations["images"];
110
113
  delete?: never;
111
114
  options?: never;
@@ -331,6 +334,118 @@ interface paths {
331
334
  patch?: never;
332
335
  trace?: never;
333
336
  };
337
+ "/v1/chatgpt": {
338
+ parameters: {
339
+ query?: never;
340
+ header?: never;
341
+ path?: never;
342
+ cookie?: never;
343
+ };
344
+ get?: never;
345
+ put?: never;
346
+ /**
347
+ * Ask ChatGPT as a logged-out user and get its answer, cited sources, products and places (5 credits)
348
+ * @description Opens chatgpt.com as a logged-out visitor in a standard Chrome behind our
349
+ * proxies, sends `prompt` and returns the answer. With `web_search` (default
350
+ * true) ChatGPT searches the web; `false` lets it decide. ChatGPT localises
351
+ * prices, shops and places to where the visitor is: set `country` to ask from
352
+ * an exit in that country (residential proxies), or leave it out to ask from
353
+ * any of our exits. Guests get ChatGPT's default free model (`model`).
354
+ * Takes 20–90 s; failed or refused answers are free.
355
+ */
356
+ post: operations["chatgpt"];
357
+ delete?: never;
358
+ options?: never;
359
+ head?: never;
360
+ patch?: never;
361
+ trace?: never;
362
+ };
363
+ "/v1/gemini": {
364
+ parameters: {
365
+ query?: never;
366
+ header?: never;
367
+ path?: never;
368
+ cookie?: never;
369
+ };
370
+ get?: never;
371
+ put?: never;
372
+ /**
373
+ * Ask Google Gemini as a logged-out user and get its answer with the sources it grounded on (5 credits)
374
+ * @description Opens gemini.google.com as a logged-out visitor and sends `prompt`. Gemini
375
+ * answers guests from residential and ISP exits only; grounded answers take
376
+ * 40–90 s. `country` asks from an exit in that country.
377
+ */
378
+ post: operations["gemini"];
379
+ delete?: never;
380
+ options?: never;
381
+ head?: never;
382
+ patch?: never;
383
+ trace?: never;
384
+ };
385
+ "/v1/copilot": {
386
+ parameters: {
387
+ query?: never;
388
+ header?: never;
389
+ path?: never;
390
+ cookie?: never;
391
+ };
392
+ get?: never;
393
+ put?: never;
394
+ /**
395
+ * Ask Microsoft Copilot Search on Bing and get its answer, cited sources and products (3 credits)
396
+ * @description Microsoft Copilot Search (bing.com/copilotsearch, Bing's AI answer).
397
+ * The Copilot app itself has no logged-out access. `country` and `language`
398
+ * set Bing's market. Products are Bing's sponsored product cards. 15–40 s.
399
+ */
400
+ post: operations["copilot"];
401
+ delete?: never;
402
+ options?: never;
403
+ head?: never;
404
+ patch?: never;
405
+ trace?: never;
406
+ };
407
+ "/v1/ai_mode": {
408
+ parameters: {
409
+ query?: never;
410
+ header?: never;
411
+ path?: never;
412
+ cookie?: never;
413
+ };
414
+ get?: never;
415
+ put?: never;
416
+ /**
417
+ * Ask Google AI Mode and get its answer, cited sources and products (3 credits)
418
+ * @description Google's AI Mode (`udm=50`) for `prompt`, logged out. `country` is the
419
+ * country Google answers for. 10–45 s.
420
+ */
421
+ post: operations["aiMode"];
422
+ delete?: never;
423
+ options?: never;
424
+ head?: never;
425
+ patch?: never;
426
+ trace?: never;
427
+ };
428
+ "/v1/brave_ai": {
429
+ parameters: {
430
+ query?: never;
431
+ header?: never;
432
+ path?: never;
433
+ cookie?: never;
434
+ };
435
+ get?: never;
436
+ put?: never;
437
+ /**
438
+ * Ask Brave Search's AI answer and get it with cited sources, the searches it ran and products (2 credits)
439
+ * @description Brave Search's AI answer ("Ask Brave") for `prompt`, logged out. `country`
440
+ * sets Brave's market (prices and shops follow it). About 10 s.
441
+ */
442
+ post: operations["braveAi"];
443
+ delete?: never;
444
+ options?: never;
445
+ head?: never;
446
+ patch?: never;
447
+ trace?: never;
448
+ };
334
449
  "/v1/extract": {
335
450
  parameters: {
336
451
  query?: never;
@@ -341,10 +456,19 @@ interface paths {
341
456
  get?: never;
342
457
  put?: never;
343
458
  /**
344
- * Up to 20 URLs (HTML or PDF) as Markdown, text or HTML, with query-ranked highlights, links and images (1 credit per URL read)
459
+ * Up to 20 URLs (HTML or PDF) as Markdown, text or HTML, with query-ranked highlights, links, images, an AI summary or JSON extracted with a schema (1 credit per URL read)
345
460
  * @description Every URL is billed only when it comes back: 1 credit, 0.5 from cache. URLs that
346
461
  * fail are listed in `failed` and cost nothing. The response is `200` even when every
347
462
  * URL failed. Highlights are ranked with BM25 (lexical, no model).
463
+ *
464
+ * **AI:** `summary: true` adds a 3–6 sentence summary of each page (+4 credits per
465
+ * page); `output_schema` (a JSON Schema, at most 16 KB, optionally guided by
466
+ * `prompt`) returns each page's data as JSON in `output` (+4 credits per page).
467
+ * Claude Haiku writes both; a schema whose fields are all booleans or enums is
468
+ * answered by a decision model instead (always valid against the schema). A
469
+ * summary or extraction that fails is reported in `summary_error` /
470
+ * `output_error` and not charged. With either, `timeout` defaults to 75 seconds
471
+ * and the last 25 are kept for the model.
348
472
  */
349
473
  post: operations["extract"];
350
474
  delete?: never;
@@ -437,6 +561,106 @@ interface paths {
437
561
  patch?: never;
438
562
  trace?: never;
439
563
  };
564
+ "/v1/answer": {
565
+ parameters: {
566
+ query?: never;
567
+ header?: never;
568
+ path?: never;
569
+ cookie?: never;
570
+ };
571
+ get?: never;
572
+ put?: never;
573
+ /**
574
+ * A cited answer grounded on live Google results, written by Claude (fast = 1 + 2 credits; standard = 1 + 1 per page read + 4)
575
+ * @description Runs the query on Google, then Claude (Haiku by default) writes a concise answer
576
+ * that cites the numbered `results` with `[n]` markers. `depth=fast` answers from
577
+ * the result page (snippets, answer box, knowledge panel); `depth=standard`
578
+ * (default) also reads the top `num_sources` pages and answers from their
579
+ * query-ranked passages. Sources are untrusted: instructions inside pages are
580
+ * ignored.
581
+ *
582
+ * **Billing:** the search part is priced like `/v1/search` with `include_content`
583
+ * (1 credit + 1 per page read, cache rules as usual); the model adds 2 credits at
584
+ * `fast` and 4 when it read pages (`standard`; 2 if no page could be read).
585
+ * `meta.credits` splits the two. When the model fails the answer part is refunded
586
+ * (`503 ai_unavailable`); a search that returned nothing to answer from is answered
587
+ * with `answer: null`, a warning, and no model charge.
588
+ *
589
+ * **Structured output:** with `output_schema` (a JSON Schema, at most 16 KB) the
590
+ * answer is a JSON value in `output` (and `answer` is null). Can't be combined
591
+ * with `stream`.
592
+ *
593
+ * **Streaming:** `stream: true` returns `text/event-stream` with these events, in
594
+ * order: `results` (`{request, results}`), `delta` (`{text}`, repeated), then
595
+ * `done` (`{answer, citations, meta}`) or `error` (`{error}`). Billing headers on a
596
+ * stream carry the search part only; the final `meta` has the total.
597
+ */
598
+ post: operations["answer"];
599
+ delete?: never;
600
+ options?: never;
601
+ head?: never;
602
+ patch?: never;
603
+ trace?: never;
604
+ };
605
+ "/v1/research": {
606
+ parameters: {
607
+ query?: never;
608
+ header?: never;
609
+ path?: never;
610
+ cookie?: never;
611
+ };
612
+ get?: never;
613
+ put?: never;
614
+ /**
615
+ * Start an async deep-research task — planned searches, page reading, a cited Markdown report written by Claude (lite 30, standard 75, deep 200 credits)
616
+ * @description Claude plans Google queries for `input`, the pages they find are read and
617
+ * ranked, a decision model checks whether the notes already cover the task (and
618
+ * drops off-topic sources), Claude reviews gaps and plans follow-up rounds, then
619
+ * writes a Markdown report citing numbered sources (and, with `output_schema`, a
620
+ * JSON value in `output`).
621
+ *
622
+ * | effort | credits | first-round queries | rounds | pages per query |
623
+ * |---|---:|---:|---:|---:|
624
+ * | lite | 30 | 3 | 1 | 2 |
625
+ * | standard | 75 | 5 | 2 | 3 |
626
+ * | deep | 200 | 8 | 3 | 4 |
627
+ *
628
+ * The flat price is reserved at enqueue and charged only when the report is
629
+ * written; failed research is refunded. A canceled task is charged 1 credit per
630
+ * search already run. Returns `202`; poll `GET /v1/research/{id}` or wait for the
631
+ * signed `research.completed` webhook. At most 20 crawl and research tasks per
632
+ * account may be queued or running at once (`429`).
633
+ */
634
+ post: operations["createResearch"];
635
+ delete?: never;
636
+ options?: never;
637
+ head?: never;
638
+ patch?: never;
639
+ trace?: never;
640
+ };
641
+ "/v1/research/{id}": {
642
+ parameters: {
643
+ query?: never;
644
+ header?: never;
645
+ path: {
646
+ id: string;
647
+ };
648
+ cookie?: never;
649
+ };
650
+ /** Poll a research task (kept for 24 hours) */
651
+ get: operations["getResearch"];
652
+ put?: never;
653
+ post?: never;
654
+ /**
655
+ * Cancel a research task. A queued task is refunded at once; a running one stops at its next round and is charged for the searches run
656
+ * @description `404` when there is no such task, `409` when it already finished.
657
+ */
658
+ delete: operations["cancelResearch"];
659
+ options?: never;
660
+ head?: never;
661
+ patch?: never;
662
+ trace?: never;
663
+ };
440
664
  "/v1/monitors": {
441
665
  parameters: {
442
666
  query?: never;
@@ -463,6 +687,13 @@ interface paths {
463
687
  * account (403 `forbidden`). A monitor pauses itself after 10 failed runs in a row
464
688
  * (search errors, insufficient credits or webhook failures) or when its key is
465
689
  * revoked; set `active: true` to resume.
690
+ *
691
+ * With an AI assistant `endpoint` (chatgpt, gemini, copilot, ai_mode,
692
+ * brave_ai) the monitor asks `prompt` every run and reports every answer
693
+ * (AI visibility is tracked over time): `text`, `markdown`, `sources`,
694
+ * `new_sources` (links not seen in earlier runs), `search_queries`,
695
+ * `products` and, with `track`, `mentions`. Each run costs the endpoint's
696
+ * price.
466
697
  */
467
698
  post: operations["createMonitor"];
468
699
  delete?: never;
@@ -604,7 +835,8 @@ interface paths {
604
835
  * @description Credits for the whole batch are reserved together: if the balance, spend cap, key limit or
605
836
  * free daily cap can't cover every valid request, none is queued and each gets the error
606
837
  * (invalid requests get their own 400 entry either way). Each job is settled and refunded on
607
- * its own once it runs.
838
+ * its own once it runs. Half price applies to the search part; an AI surcharge
839
+ * (`include_answer`) is charged in full.
608
840
  *
609
841
  * **Retries.** Send an `Idempotency-Key` to make the call safe to retry: for 24 hours a
610
842
  * repeat with the same key and the same body returns the first response (with
@@ -803,7 +1035,7 @@ interface components {
803
1035
  /** @description Map point "@lat,lng,14z" (maps and places only; zoom optional, default 14z): the map is searched around that point at that zoom, wherever the request comes from. Overrides location */
804
1036
  ll?: string;
805
1037
  /**
806
- * @description 10, or up to 100 for the depth bundle on search and news (7 credits for 100; values between round up to whole pages). Other verticals return one page of 10
1038
+ * @description 1–100. Up to 10 returns one page (10 results, 1 credit; trim it yourself for fewer). Above 10 on search and news is the depth bundle (7 credits for 100; values between round up to whole pages). On images a page is a block of up to 100 images (1 credit) and num (default 100) is how many of them to return; `page` moves to the next block. Other verticals return one page of 10
807
1039
  * @default 10
808
1040
  */
809
1041
  num?: number;
@@ -848,9 +1080,9 @@ interface components {
848
1080
  /** @description Accept a cached result up to this many seconds old (50% of credits on a hit) */
849
1081
  max_age?: number;
850
1082
  engine?: components["schemas"]["EngineParam"];
851
- /** @description Only results from these domains (search, news, images, videos). Compiled into site: operators and enforced on the results. Not with engine=consensus */
1083
+ /** @description Only results from these domains (search, news, images, videos). Compiled into site: operators and enforced on the results. With engine=consensus, every provider gets the operators and only providers with a remaining result are billed */
852
1084
  include_domains?: components["schemas"]["DomainList"];
853
- /** @description Drop results from these domains (search, news, images, videos). Not with engine=consensus */
1085
+ /** @description Drop results from these domains (search, news, images, videos) */
854
1086
  exclude_domains?: components["schemas"]["DomainList"];
855
1087
  /** @description Move results from these domains to the top, keeping the order within both groups (search, news) */
856
1088
  boost_domains?: components["schemas"]["DomainList"];
@@ -869,6 +1101,11 @@ interface components {
869
1101
  * @default false
870
1102
  */
871
1103
  highlights?: boolean;
1104
+ /**
1105
+ * @description Add a cited AI `answer` written by Claude over this response's results (search and news; +2 credits, +4 when it read pages via `include_content`; refunded with a `meta.warnings` entry when the model fails)
1106
+ * @default false
1107
+ */
1108
+ include_answer?: boolean;
872
1109
  };
873
1110
  /** @description Domains as an array or a comma-separated string, at most 20: a host (`example.com`, subdomains match), a host with a path prefix (`github.com/org`) or a TLD (`.gov`). */
874
1111
  DomainList: string | string[];
@@ -938,6 +1175,135 @@ interface components {
938
1175
  max_age?: number;
939
1176
  engine?: components["schemas"]["EngineParam"];
940
1177
  };
1178
+ AssistantRequest: {
1179
+ /** @description The message to the assistant */
1180
+ prompt: string;
1181
+ /** @description Ask from this country (ISO 3166-1 alpha-2): answers, prices and shops follow it */
1182
+ country?: string;
1183
+ /** @description Interface language (e.g. en, de); the answer follows the prompt's language */
1184
+ language?: string;
1185
+ track?: components["schemas"]["TrackList"];
1186
+ /**
1187
+ * @description Also return the answer page's HTML (`html`)
1188
+ * @default false
1189
+ */
1190
+ include_html?: boolean;
1191
+ /**
1192
+ * @default json
1193
+ * @enum {string}
1194
+ */
1195
+ format?: "json" | "markdown" | "compact";
1196
+ fields?: string;
1197
+ /** @description Accept a cached answer up to this many seconds old (half price); answers are cached for at most an hour */
1198
+ max_age?: number;
1199
+ };
1200
+ ChatGPTRequest: {
1201
+ /** @description The message to ChatGPT */
1202
+ prompt: string;
1203
+ /**
1204
+ * @description Make ChatGPT search the web; false lets it decide (it then searches for about two thirds of shopping and local prompts)
1205
+ * @default true
1206
+ */
1207
+ web_search?: boolean;
1208
+ /** @description Ask from an exit in this country (ISO 3166-1 alpha-2, residential proxies). Without it any of our exits asks (mostly US and EU) */
1209
+ country?: string;
1210
+ track?: components["schemas"]["TrackList"];
1211
+ /** @default false */
1212
+ include_html?: boolean;
1213
+ /**
1214
+ * @default json
1215
+ * @enum {string}
1216
+ */
1217
+ format?: "json" | "markdown" | "compact";
1218
+ fields?: string;
1219
+ max_age?: number;
1220
+ };
1221
+ /** @description Brands ("Acme") and domains ("acme.com", subdomains match) to check the answer for; each comes back in `mentions` */
1222
+ TrackList: string[];
1223
+ AISource: {
1224
+ /** @description The number the answer cites it with ([n] in markdown) */
1225
+ position: number;
1226
+ title?: string;
1227
+ link: string;
1228
+ domain: string;
1229
+ snippet?: string;
1230
+ date?: string;
1231
+ /** @description Cited inline in the answer (false: only listed beside it) */
1232
+ cited: boolean;
1233
+ };
1234
+ AIProduct: {
1235
+ position: number;
1236
+ title: string;
1237
+ brand?: string;
1238
+ /** @description As shown */
1239
+ price?: string;
1240
+ extracted_price?: number;
1241
+ /** @description ISO 4217 when the symbol is unambiguous */
1242
+ currency?: string;
1243
+ rating?: number;
1244
+ reviews?: number;
1245
+ merchant?: string;
1246
+ link?: string;
1247
+ image?: string;
1248
+ description?: string;
1249
+ /** @description A paid placement (an ad card shown with the answer) */
1250
+ sponsored?: boolean;
1251
+ };
1252
+ Mention: {
1253
+ term: string;
1254
+ /** @description The answer text names it (a domain: names the domain) */
1255
+ mentioned: boolean;
1256
+ /** @description A cited source matches it */
1257
+ cited: boolean;
1258
+ /** @description Positions of the matching sources */
1259
+ sources: number[];
1260
+ /** @description Positions of the matching products */
1261
+ products?: number[];
1262
+ /** @description Where the text first names it, 0 (start) to 1 (end); -1 when it doesn't */
1263
+ text_position: number;
1264
+ };
1265
+ /** @description The normalised request of an AI assistant endpoint (the path names the assistant, so there is no engine) */
1266
+ AssistantEcho: {
1267
+ /**
1268
+ * @example chatgpt
1269
+ * @example gemini
1270
+ */
1271
+ endpoint: string;
1272
+ prompt: string;
1273
+ country?: string;
1274
+ /** @description Not on chatgpt */
1275
+ language?: string;
1276
+ /** @description chatgpt only */
1277
+ web_search?: boolean;
1278
+ include_html?: boolean;
1279
+ };
1280
+ AssistantResponse: {
1281
+ request: components["schemas"]["AssistantEcho"];
1282
+ /** @description The answer as plain text */
1283
+ text: string;
1284
+ /** @description The answer as Markdown, citations as [n](link) matching sources[].position */
1285
+ markdown: string;
1286
+ /** @description Only with include_html=true */
1287
+ html?: string;
1288
+ /** @description The model the assistant reports, when it does (e.g. ChatGPT's guest model) */
1289
+ model?: string;
1290
+ sources: components["schemas"]["AISource"][];
1291
+ /** @description The searches the assistant ran (fan-out) where it shows them */
1292
+ search_queries: string[];
1293
+ products: components["schemas"]["AIProduct"][];
1294
+ /** @description Local businesses the answer showed */
1295
+ places?: components["schemas"]["PlaceResult"][];
1296
+ related_questions?: string[];
1297
+ /** @description With track only */
1298
+ mentions?: components["schemas"]["Mention"][];
1299
+ meta: components["schemas"]["Meta"];
1300
+ };
1301
+ AIOverview: {
1302
+ text: string;
1303
+ /** @description Citations as [n](link) matching sources[].position */
1304
+ markdown: string;
1305
+ sources: components["schemas"]["AISource"][];
1306
+ };
941
1307
  WebpageRequest: {
942
1308
  /**
943
1309
  * Format: uri
@@ -991,10 +1357,21 @@ interface components {
991
1357
  /** @description Fetch through an exit in this country (ISO 3166-1 alpha-2) */
992
1358
  country?: string;
993
1359
  /**
994
- * @description Seconds to wait for the pages; a page still loading is listed in `failed` (`upstream_timeout`, not charged)
1360
+ * @description Seconds to wait for the pages; a page still loading is listed in `failed` (`upstream_timeout`, not charged). Default 75 with summary or output_schema
995
1361
  * @default 50
996
1362
  */
997
1363
  timeout?: number;
1364
+ /**
1365
+ * @description Add a 3-6 sentence AI summary of each page (+4 credits per page; focused on `query` when set)
1366
+ * @default false
1367
+ */
1368
+ summary?: boolean;
1369
+ /** @description A JSON Schema (at most 16 KB): each page's data is returned as JSON matching it in `output` (+4 credits per page) */
1370
+ output_schema?: {
1371
+ [key: string]: unknown;
1372
+ };
1373
+ /** @description Guides output_schema extraction (what to pick, how to normalise); needs output_schema */
1374
+ prompt?: string;
998
1375
  };
999
1376
  ExtractResult: {
1000
1377
  /** @description Final URL after redirects */
@@ -1017,6 +1394,12 @@ interface components {
1017
1394
  images?: string[];
1018
1395
  /** @description highlights > 0 only */
1019
1396
  highlights?: components["schemas"]["Highlight"][];
1397
+ /** @description summary=true only (null when it failed) */
1398
+ summary?: string | null;
1399
+ summary_error?: string;
1400
+ /** @description output_schema only: the JSON value matching the schema (null when it failed) */
1401
+ output?: unknown;
1402
+ output_error?: string;
1020
1403
  };
1021
1404
  ExtractFailure: {
1022
1405
  url: string;
@@ -1049,8 +1432,189 @@ interface components {
1049
1432
  latency_ms?: number;
1050
1433
  succeeded: number;
1051
1434
  failed: number;
1435
+ llm?: components["schemas"]["LLMUsage"];
1052
1436
  };
1053
1437
  };
1438
+ AnswerRequest: {
1439
+ q: string;
1440
+ /**
1441
+ * @description `fast` answers from the result page (1 + 2 credits); `standard` also reads the top `num_sources` pages (1 + 1 per page + 4 credits)
1442
+ * @default standard
1443
+ * @enum {string}
1444
+ */
1445
+ depth?: "fast" | "standard";
1446
+ /**
1447
+ * @description Pages read (depth=standard only)
1448
+ * @default 3
1449
+ */
1450
+ num_sources?: number;
1451
+ /**
1452
+ * @description Send Server-Sent Events (`results`, `delta`…, `done` | `error`) instead of one JSON body
1453
+ * @default false
1454
+ */
1455
+ stream?: boolean;
1456
+ /** @description A JSON Schema (at most 16 KB). The answer becomes a JSON value in `output`. Not with stream */
1457
+ output_schema?: {
1458
+ [key: string]: unknown;
1459
+ };
1460
+ /** @default us */
1461
+ country?: string;
1462
+ /** @default en */
1463
+ language?: string;
1464
+ location?: string;
1465
+ uule?: string;
1466
+ /** @enum {string} */
1467
+ time?: "hour" | "day" | "week" | "month" | "year";
1468
+ tbs?: string;
1469
+ /**
1470
+ * @default desktop
1471
+ * @enum {string}
1472
+ */
1473
+ device?: "desktop" | "mobile";
1474
+ /**
1475
+ * @default off
1476
+ * @enum {string}
1477
+ */
1478
+ safe?: "active" | "off";
1479
+ /** @default true */
1480
+ autocorrect?: boolean;
1481
+ /** @description Accept a cached search up to this many seconds old */
1482
+ max_age?: number;
1483
+ engine?: components["schemas"]["EngineParam"];
1484
+ include_domains?: components["schemas"]["DomainList"];
1485
+ exclude_domains?: components["schemas"]["DomainList"];
1486
+ boost_domains?: components["schemas"]["DomainList"];
1487
+ /** Format: date */
1488
+ start_date?: string;
1489
+ /** Format: date */
1490
+ end_date?: string;
1491
+ };
1492
+ /** @description A result the answer may cite, numbered as in the prompt (`[index]`) */
1493
+ AnswerSource: {
1494
+ index: number;
1495
+ title: string;
1496
+ link: string;
1497
+ domain?: string;
1498
+ /** @description Publish date (ISO 8601 when known, else as shown) */
1499
+ date?: string;
1500
+ };
1501
+ AnswerMeta: components["schemas"]["Meta"] & {
1502
+ /** @description `credits_used` split into the search and the model part */
1503
+ credits?: {
1504
+ search?: number;
1505
+ answer?: number;
1506
+ };
1507
+ };
1508
+ AnswerResponse: {
1509
+ request: components["schemas"]["RequestEcho"];
1510
+ /** @description Markdown with `[n]` citation markers. Null with output_schema, or when there was nothing to answer from */
1511
+ answer: string | null;
1512
+ /** @description output_schema only: the JSON value matching the schema */
1513
+ output?: unknown;
1514
+ /** @description The sources the answer cites, in first-cited order */
1515
+ citations: components["schemas"]["Citation"][];
1516
+ results: components["schemas"]["AnswerSource"][];
1517
+ meta: components["schemas"]["AnswerMeta"];
1518
+ };
1519
+ /** @description `event: results`, sent first */
1520
+ AnswerStreamResults: {
1521
+ request: components["schemas"]["RequestEcho"];
1522
+ results: components["schemas"]["AnswerSource"][];
1523
+ };
1524
+ /** @description `event: delta`: the next piece of answer text */
1525
+ AnswerStreamDelta: {
1526
+ text: string;
1527
+ };
1528
+ /** @description `event: done`, sent last: the final answer (citation markers checked) and meta with the total credits */
1529
+ AnswerStreamDone: {
1530
+ answer: string;
1531
+ citations: components["schemas"]["Citation"][];
1532
+ meta: components["schemas"]["AnswerMeta"];
1533
+ };
1534
+ ResearchRequest: {
1535
+ /** @description The research task in plain words (`q` is accepted as an alias) */
1536
+ input: string;
1537
+ /**
1538
+ * @description lite = 30, standard = 75, deep = 200 credits
1539
+ * @default standard
1540
+ * @enum {string}
1541
+ */
1542
+ effort?: "lite" | "standard" | "deep";
1543
+ /** @description A JSON Schema (at most 16 KB); the report is also returned as a JSON value in `result.output` */
1544
+ output_schema?: {
1545
+ [key: string]: unknown;
1546
+ };
1547
+ country?: string;
1548
+ language?: string;
1549
+ include_domains?: string[];
1550
+ exclude_domains?: string[];
1551
+ /**
1552
+ * Format: uri
1553
+ * @description Receives the signed `research.completed` event. Defaults to the account webhook
1554
+ */
1555
+ webhook_url?: string;
1556
+ };
1557
+ ResearchSource: {
1558
+ index: number;
1559
+ title: string;
1560
+ link: string;
1561
+ domain?: string;
1562
+ published_at?: string;
1563
+ /** @description The query that found it */
1564
+ query?: string;
1565
+ };
1566
+ ResearchResult: {
1567
+ input: string;
1568
+ /** @enum {string} */
1569
+ effort: "lite" | "standard" | "deep";
1570
+ /** @description Markdown report with `[n]` citation markers */
1571
+ report: string;
1572
+ citations: components["schemas"]["Citation"][];
1573
+ sources: components["schemas"]["ResearchSource"][];
1574
+ /** @description Every search the research ran */
1575
+ queries: string[];
1576
+ stats?: {
1577
+ searches?: number;
1578
+ sources?: number;
1579
+ rounds?: number;
1580
+ };
1581
+ llm?: components["schemas"]["LLMUsage"];
1582
+ /** @description output_schema only: the JSON value (null when it could not be produced) */
1583
+ output?: unknown;
1584
+ output_error?: string;
1585
+ };
1586
+ ResearchTask: {
1587
+ /** Format: uuid */
1588
+ id: string;
1589
+ /** @constant */
1590
+ kind: "research";
1591
+ status: components["schemas"]["TaskStatus"];
1592
+ /** Format: date-time */
1593
+ created_at: string;
1594
+ /** Format: date-time */
1595
+ started_at?: string | null;
1596
+ /** Format: date-time */
1597
+ completed_at?: string | null;
1598
+ credits_reserved: number;
1599
+ credits_used: number;
1600
+ /** @enum {string|null} */
1601
+ webhook_status?: "pending" | "delivered" | "failed" | null;
1602
+ progress?: ({
1603
+ round?: number;
1604
+ rounds?: number;
1605
+ queries?: number;
1606
+ sources?: number;
1607
+ /** @enum {string} */
1608
+ step?: "searching" | "reviewing" | "writing";
1609
+ } & {
1610
+ [key: string]: unknown;
1611
+ }) | null;
1612
+ /** @description Set once the report is written (a failed or canceled task may carry only `queries`) */
1613
+ result?: components["schemas"]["ResearchResult"] | {
1614
+ [key: string]: unknown;
1615
+ } | null;
1616
+ error?: components["schemas"]["TaskError"];
1617
+ };
1054
1618
  CrawlRequest: {
1055
1619
  /**
1056
1620
  * Format: uri
@@ -1112,7 +1676,7 @@ interface components {
1112
1676
  /** Format: uuid */
1113
1677
  id: string;
1114
1678
  /** @enum {string} */
1115
- kind: "crawl";
1679
+ kind: "crawl" | "research";
1116
1680
  status: components["schemas"]["TaskStatus"];
1117
1681
  /** Format: date-time */
1118
1682
  created_at: string;
@@ -1217,7 +1781,7 @@ interface components {
1217
1781
  * @description The site (any page of it; sitemaps are read from its origin)
1218
1782
  */
1219
1783
  url: string;
1220
- /** @description Keep only URLs relevant to these words, most relevant first */
1784
+ /** @description Keep only URLs relevant to these words, most relevant first. When the sitemap lists fewer than 50 URLs, up to 8 of the start page's links are read too, one level deeper */
1221
1785
  search?: string;
1222
1786
  /** @default 100 */
1223
1787
  limit?: number;
@@ -1275,7 +1839,7 @@ interface components {
1275
1839
  * @enum {string}
1276
1840
  */
1277
1841
  Provider: "google" | "brave" | "bing" | "yahoo" | "duckduckgo" | "mojeek" | "wikipedia" | "yandex";
1278
- /** @description Which search providers may answer. `google` (the default) is Google only; within Google, SerpKite always fails over across its own proxy pools. `auto` allows falling back to other enabled providers, in route order, when Google is blocked or times out. A single other provider (`brave`) or a list (`["google","brave"]`, or `google,brave` in a query string) restricts the request to those providers. `meta.engine` always names the provider that answered and credits follow that provider's price. A key with "Allow fallback to other search engines" on treats a request without `engine` as `auto`. `consensus` (`/v1/search` only; 400 elsewhere, and it can't be combined with other names) queries several independent search indexes in parallel (at most one Bing-backed provider, so Yahoo or DuckDuckGo never count as agreeing with Bing), merges the results by URL and ranks them by how many providers returned each one. Each result lists its `sources`; `meta.engine` is `consensus` and `meta.route` lists every provider attempt. It stops once `num` unique results are in hand or after a few seconds, and costs the sum of one page at each provider that returned results (providers that failed, came back empty or were never started are free). `yandex` serves `/v1/maps`, `/v1/places` and `/v1/place` from Yandex Maps where the deployment enables it (otherwise a 503 `unavailable`, not charged); with `auto` it is the last fallback there. */
1842
+ /** @description Which search providers may answer. `google` (the default) is Google only; within Google, SerpKite always fails over across its own proxy pools. `auto` allows falling back to other enabled providers, in route order, when Google is blocked or times out. A single other provider (`brave`) or a list (`["google","brave"]`, or `google,brave` in a query string) restricts the request to those providers. `meta.engine` always names the provider that answered and credits follow that provider's price. A key with "Allow fallback to other search engines" on treats a request without `engine` as `auto`. `consensus` (`/v1/search` only; 400 elsewhere, and it can't be combined with other names) queries several independent search indexes in parallel (at most one Bing-backed provider, so Yahoo or DuckDuckGo never count as agreeing with Bing), merges the results by URL and ranks them by how many providers returned each one. Each result lists its `sources`; `meta.engine` is `consensus` and `meta.route` lists every provider attempt. Up to three providers answer: a provider that fails or comes back empty hands its turn to the next one in the route. It stops once `num` unique results are in hand or after a few seconds, and costs the sum of one page at each provider that returned results (providers that failed, came back empty or were never started are free). `yandex` serves `/v1/search` from Yandex web search (no `time` filter or `safe: active`: a request naming it gets a 400 with them) and `/v1/maps`, `/v1/places` and `/v1/place` from Yandex Maps, where the deployment enables it (otherwise a 503 `unavailable`, not charged); with `auto` it is the last fallback there. */
1279
1843
  EngineParam: string | components["schemas"]["Provider"][];
1280
1844
  /** @description One provider attempt behind this answer. Proxy pools are internal and never listed. */
1281
1845
  RouteStep: {
@@ -1309,6 +1873,37 @@ interface components {
1309
1873
  /** @enum {string} */
1310
1874
  parse_quality?: "ok" | "partial" | "empty";
1311
1875
  latency_ms?: number;
1876
+ llm?: components["schemas"]["LLMUsage"];
1877
+ /** @description Non-fatal problems, e.g. an include_answer that failed (and was refunded) */
1878
+ warnings?: string[];
1879
+ };
1880
+ /** @description The model that wrote this response's AI part and the tokens it used */
1881
+ LLMUsage: {
1882
+ /**
1883
+ * @example anthropic
1884
+ * @example openai
1885
+ */
1886
+ provider?: string;
1887
+ /**
1888
+ * @example claude-haiku-5-5
1889
+ * @example gpt-6-luna
1890
+ */
1891
+ model?: string;
1892
+ input_tokens?: number;
1893
+ output_tokens?: number;
1894
+ };
1895
+ Citation: {
1896
+ /** @description The `[n]` marker used in the text (1-based source number) */
1897
+ index: number;
1898
+ title: string;
1899
+ link: string;
1900
+ domain?: string;
1901
+ };
1902
+ /** @description include_answer: a cited answer over this response's results */
1903
+ SearchAnswer: {
1904
+ /** @description Markdown with `[n]` citation markers (n = the numbered sources: answer box, knowledge panel, then results) */
1905
+ text: string;
1906
+ citations: components["schemas"]["Citation"][];
1312
1907
  };
1313
1908
  /** @description The normalised request that produced this response (defaults filled in) */
1314
1909
  RequestEcho: {
@@ -1316,6 +1911,7 @@ interface components {
1316
1911
  * @example search
1317
1912
  * @example news
1318
1913
  * @example webpage
1914
+ * @example chatgpt
1319
1915
  */
1320
1916
  endpoint: string;
1321
1917
  /** @description The engine policy as asked (google, auto, one provider or a list) */
@@ -1346,6 +1942,12 @@ interface components {
1346
1942
  exclude_domains?: string[];
1347
1943
  boost_domains?: string[];
1348
1944
  highlights?: boolean;
1945
+ include_answer?: boolean;
1946
+ /** @description AI assistant endpoints */
1947
+ prompt?: string;
1948
+ /** @description /v1/chatgpt */
1949
+ web_search?: boolean;
1950
+ include_html?: boolean;
1349
1951
  } & {
1350
1952
  [key: string]: unknown;
1351
1953
  };
@@ -1428,6 +2030,9 @@ interface components {
1428
2030
  related_searches: components["schemas"]["RelatedSearch"][];
1429
2031
  top_stories?: components["schemas"]["NewsResult"][];
1430
2032
  places?: components["schemas"]["PlaceResult"][];
2033
+ answer?: components["schemas"]["SearchAnswer"];
2034
+ /** @description Google's AI Overview when the page showed one */
2035
+ ai_overview?: components["schemas"]["AIOverview"];
1431
2036
  meta: components["schemas"]["Meta"];
1432
2037
  };
1433
2038
  ImageResult: {
@@ -1480,6 +2085,7 @@ interface components {
1480
2085
  NewsResponse: {
1481
2086
  request: components["schemas"]["RequestEcho"];
1482
2087
  results: components["schemas"]["NewsResult"][];
2088
+ answer?: components["schemas"]["SearchAnswer"];
1483
2089
  meta: components["schemas"]["Meta"];
1484
2090
  };
1485
2091
  PlaceResult: {
@@ -1773,7 +2379,7 @@ interface components {
1773
2379
  };
1774
2380
  BatchCreateRequest: {
1775
2381
  /** @enum {string} */
1776
- endpoint: "search" | "images" | "videos" | "news" | "maps" | "places" | "place" | "reviews" | "shopping" | "scholar" | "patents" | "autocomplete" | "webpage";
2382
+ endpoint: "search" | "images" | "videos" | "news" | "maps" | "places" | "place" | "reviews" | "shopping" | "scholar" | "patents" | "autocomplete" | "webpage" | "chatgpt" | "gemini" | "copilot" | "ai_mode" | "brave_ai";
1777
2383
  /** @description Request bodies for `endpoint` (same fields as the realtime endpoint) */
1778
2384
  requests: {
1779
2385
  [key: string]: unknown;
@@ -1830,14 +2436,14 @@ interface components {
1830
2436
  requests: number;
1831
2437
  };
1832
2438
  };
1833
- /** @description Body of `crawl.completed` */
2439
+ /** @description Body of `crawl.completed` and `research.completed` */
1834
2440
  TaskCompletedEvent: {
1835
- /** @constant */
1836
- event: "crawl.completed";
2441
+ /** @enum {string} */
2442
+ event: "crawl.completed" | "research.completed";
1837
2443
  /** Format: uuid */
1838
2444
  id: string;
1839
- /** @constant */
1840
- kind: "crawl";
2445
+ /** @enum {string} */
2446
+ kind: "crawl" | "research";
1841
2447
  status: components["schemas"]["TaskStatus"];
1842
2448
  /** Format: date-time */
1843
2449
  created_at: string;
@@ -1846,7 +2452,7 @@ interface components {
1846
2452
  credits_used: number;
1847
2453
  /** @description Where the task (and its full result) can be fetched for 24 hours */
1848
2454
  poll_url?: string;
1849
- /** @description The CrawlResult (null when the crawl failed without one, or when it is larger than 4 MB: see result_omitted) */
2455
+ /** @description The CrawlResult or ResearchResult (null when the task failed without one, or when it is larger than 4 MB: see result_omitted) */
1850
2456
  result?: unknown;
1851
2457
  /** @description Set when the result was too large for the webhook; GET poll_url for it */
1852
2458
  result_omitted?: boolean;
@@ -1855,10 +2461,15 @@ interface components {
1855
2461
  message?: string;
1856
2462
  };
1857
2463
  };
1858
- /** @description The saved request a monitor reruns: a search (q and options) or, for webpage monitors, url (and country) */
2464
+ /** @description The saved request a monitor reruns: a search (q and options), for webpage monitors url (and country), or for AI assistant monitors prompt (with country, language, web_search and track) */
1859
2465
  MonitorSearch: {
1860
2466
  q?: string;
1861
2467
  url?: string;
2468
+ /** @description AI assistant monitors */
2469
+ prompt?: string;
2470
+ /** @description endpoint=chatgpt */
2471
+ web_search?: boolean;
2472
+ track?: string[];
1862
2473
  country?: string;
1863
2474
  language?: string;
1864
2475
  location?: string;
@@ -1871,7 +2482,7 @@ interface components {
1871
2482
  exclude_domains?: string[];
1872
2483
  engine?: string[];
1873
2484
  };
1874
- /** @description Search and news monitors need `q`; webpage monitors need `url` and take only `country` besides */
2485
+ /** @description Search and news monitors need `q`; webpage monitors need `url` and take only `country` besides; AI assistant monitors need `prompt` and take `country`, `language` (not chatgpt), `web_search` (chatgpt) and `track` */
1875
2486
  MonitorCreateRequest: {
1876
2487
  q?: string;
1877
2488
  /**
@@ -1879,11 +2490,16 @@ interface components {
1879
2490
  * @description endpoint=webpage: the page to watch for content changes
1880
2491
  */
1881
2492
  url?: string;
2493
+ /** @description AI assistant monitors: the prompt asked every run */
2494
+ prompt?: string;
2495
+ /** @description endpoint=chatgpt */
2496
+ web_search?: boolean;
2497
+ track?: components["schemas"]["TrackList"];
1882
2498
  /**
1883
2499
  * @default search
1884
2500
  * @enum {string}
1885
2501
  */
1886
- endpoint?: "search" | "news" | "webpage";
2502
+ endpoint?: "search" | "news" | "webpage" | "chatgpt" | "gemini" | "copilot" | "ai_mode" | "brave_ai";
1887
2503
  /** @description Your own JSON object (at most 2 KB), echoed on the monitor and in its webhooks */
1888
2504
  metadata?: {
1889
2505
  [key: string]: unknown;
@@ -1935,11 +2551,14 @@ interface components {
1935
2551
  [key: string]: unknown;
1936
2552
  } | null;
1937
2553
  /**
1938
- * @description Switching between a search and a page drops the other kind's fields
2554
+ * @description Switching between a search, a page and an AI prompt drops the other kinds' fields
1939
2555
  * @enum {string}
1940
2556
  */
1941
- endpoint?: "search" | "news" | "webpage";
2557
+ endpoint?: "search" | "news" | "webpage" | "chatgpt" | "gemini" | "copilot" | "ai_mode" | "brave_ai";
1942
2558
  q?: string;
2559
+ prompt?: string;
2560
+ web_search?: boolean;
2561
+ track?: components["schemas"]["TrackList"];
1943
2562
  /**
1944
2563
  * Format: uri
1945
2564
  * @description endpoint=webpage only
@@ -1964,7 +2583,7 @@ interface components {
1964
2583
  id: string;
1965
2584
  name: string;
1966
2585
  /** @enum {string} */
1967
- endpoint: "search" | "news" | "webpage";
2586
+ endpoint: "search" | "news" | "webpage" | "chatgpt" | "gemini" | "copilot" | "ai_mode" | "brave_ai";
1968
2587
  request: components["schemas"]["MonitorSearch"];
1969
2588
  metadata?: {
1970
2589
  [key: string]: unknown;
@@ -1997,7 +2616,7 @@ interface components {
1997
2616
  status: "ok" | "error" | "webhook_failed" | "paused";
1998
2617
  error?: string | null;
1999
2618
  new_results: number;
2000
- /** @description The new results (OrganicResult-shaped for search, NewsResult for news, MonitorPageChange for webpage); null when there were none or after 24 hours */
2619
+ /** @description The new results (OrganicResult-shaped for search, NewsResult for news, MonitorPageChange for webpage, one MonitorAnswer per run for AI assistants); null when there were none or after 24 hours */
2001
2620
  results?: {
2002
2621
  [key: string]: unknown;
2003
2622
  }[] | null;
@@ -2023,6 +2642,19 @@ interface components {
2023
2642
  markdown: string;
2024
2643
  published_at?: string;
2025
2644
  };
2645
+ /** @description What an AI assistant monitor reports every run (one item per run) */
2646
+ MonitorAnswer: {
2647
+ text: string;
2648
+ markdown: string;
2649
+ model?: string;
2650
+ sources: components["schemas"]["AISource"][];
2651
+ /** @description Links of the sources not seen in earlier runs */
2652
+ new_sources: string[];
2653
+ search_queries: string[];
2654
+ products?: components["schemas"]["AIProduct"][];
2655
+ /** @description With track only */
2656
+ mentions?: components["schemas"]["Mention"][];
2657
+ };
2026
2658
  MonitorRunList: {
2027
2659
  results: components["schemas"]["MonitorRun"][];
2028
2660
  /**
@@ -2047,11 +2679,13 @@ interface components {
2047
2679
  run_id: string;
2048
2680
  name: string;
2049
2681
  /** @enum {string} */
2050
- endpoint: "search" | "news" | "webpage";
2051
- /** @description The saved query (empty for webpage monitors) */
2052
- q: string;
2682
+ endpoint: "search" | "news" | "webpage" | "chatgpt" | "gemini" | "copilot" | "ai_mode" | "brave_ai";
2683
+ /** @description The saved query (empty for webpage monitors */
2684
+ q?: string;
2053
2685
  /** @description webpage monitors only */
2054
2686
  url?: string;
2687
+ /** @description AI assistant monitors only (instead of q) */
2688
+ prompt?: string;
2055
2689
  /** @description The monitor's metadata */
2056
2690
  metadata?: {
2057
2691
  [key: string]: unknown;
@@ -2060,7 +2694,7 @@ interface components {
2060
2694
  first_run: boolean;
2061
2695
  /** Format: date-time */
2062
2696
  run_at: string;
2063
- /** @description Results not seen in earlier runs (OrganicResult-shaped for search, NewsResult for news, MonitorPageChange for webpage) */
2697
+ /** @description Results not seen in earlier runs (OrganicResult-shaped for search, NewsResult for news, MonitorPageChange for webpage); for AI assistant monitors the run's answer (one MonitorAnswer, sent every run) */
2064
2698
  new_results: {
2065
2699
  [key: string]: unknown;
2066
2700
  }[];
@@ -2398,6 +3032,22 @@ interface components {
2398
3032
  };
2399
3033
  };
2400
3034
  /** @description OK (text/markdown when format=markdown) */
3035
+ AssistantOK: {
3036
+ headers: {
3037
+ "X-Credits-Used": components["headers"]["CreditsUsed"];
3038
+ "X-Credits-Remaining": components["headers"]["CreditsRemaining"];
3039
+ "X-Cost-USD": components["headers"]["CostUSD"];
3040
+ "X-Cache": components["headers"]["Cache"];
3041
+ "X-Latency-Ms": components["headers"]["LatencyMs"];
3042
+ "X-Tokens-Estimate": components["headers"]["TokensEstimate"];
3043
+ [name: string]: unknown;
3044
+ };
3045
+ content: {
3046
+ "application/json": components["schemas"]["AssistantResponse"];
3047
+ "text/markdown": string;
3048
+ };
3049
+ };
3050
+ /** @description OK (text/markdown when format=markdown) */
2401
3051
  WebpageOK: {
2402
3052
  headers: {
2403
3053
  "X-Credits-Used": components["headers"]["CreditsUsed"];
@@ -2468,6 +3118,8 @@ interface operations {
2468
3118
  end_date?: string;
2469
3119
  /** @description Needs include_content */
2470
3120
  highlights?: boolean;
3121
+ /** @description Add a cited AI answer (+2 credits; +4 with include_content) */
3122
+ include_answer?: boolean;
2471
3123
  api_key?: string;
2472
3124
  };
2473
3125
  header?: never;
@@ -2662,9 +3314,125 @@ interface operations {
2662
3314
  path?: never;
2663
3315
  cookie?: never;
2664
3316
  };
2665
- requestBody: components["requestBodies"]["Search"];
3317
+ requestBody: components["requestBodies"]["Search"];
3318
+ responses: {
3319
+ 200: components["responses"]["ScholarOK"];
3320
+ 400: components["responses"]["Error"];
3321
+ 401: components["responses"]["Error"];
3322
+ 402: components["responses"]["Error"];
3323
+ 403: components["responses"]["Error"];
3324
+ 429: components["responses"]["Error"];
3325
+ 503: components["responses"]["Unavailable"];
3326
+ };
3327
+ };
3328
+ patents: {
3329
+ parameters: {
3330
+ query?: never;
3331
+ header?: never;
3332
+ path?: never;
3333
+ cookie?: never;
3334
+ };
3335
+ requestBody: components["requestBodies"]["Search"];
3336
+ responses: {
3337
+ 200: components["responses"]["PatentsOK"];
3338
+ 400: components["responses"]["Error"];
3339
+ 401: components["responses"]["Error"];
3340
+ 402: components["responses"]["Error"];
3341
+ 403: components["responses"]["Error"];
3342
+ 429: components["responses"]["Error"];
3343
+ 503: components["responses"]["Unavailable"];
3344
+ };
3345
+ };
3346
+ autocomplete: {
3347
+ parameters: {
3348
+ query?: never;
3349
+ header?: never;
3350
+ path?: never;
3351
+ cookie?: never;
3352
+ };
3353
+ requestBody: components["requestBodies"]["Search"];
3354
+ responses: {
3355
+ 200: components["responses"]["AutocompleteOK"];
3356
+ 400: components["responses"]["Error"];
3357
+ 401: components["responses"]["Error"];
3358
+ 402: components["responses"]["Error"];
3359
+ 403: components["responses"]["Error"];
3360
+ 429: components["responses"]["Error"];
3361
+ 503: components["responses"]["Unavailable"];
3362
+ };
3363
+ };
3364
+ webpage: {
3365
+ parameters: {
3366
+ query?: never;
3367
+ header?: never;
3368
+ path?: never;
3369
+ cookie?: never;
3370
+ };
3371
+ requestBody: {
3372
+ content: {
3373
+ "application/json": components["schemas"]["WebpageRequest"];
3374
+ };
3375
+ };
3376
+ responses: {
3377
+ 200: components["responses"]["WebpageOK"];
3378
+ 400: components["responses"]["Error"];
3379
+ 401: components["responses"]["Error"];
3380
+ 402: components["responses"]["Error"];
3381
+ 403: components["responses"]["Error"];
3382
+ 429: components["responses"]["Error"];
3383
+ 503: components["responses"]["Unavailable"];
3384
+ };
3385
+ };
3386
+ chatgpt: {
3387
+ parameters: {
3388
+ query?: never;
3389
+ header?: never;
3390
+ path?: never;
3391
+ cookie?: never;
3392
+ };
3393
+ requestBody: {
3394
+ content: {
3395
+ /**
3396
+ * @example {
3397
+ * "prompt": "What are the best CRMs for a 10-person startup?",
3398
+ * "track": [
3399
+ * "hubspot.com",
3400
+ * "Pipedrive"
3401
+ * ]
3402
+ * }
3403
+ */
3404
+ "application/json": components["schemas"]["ChatGPTRequest"];
3405
+ };
3406
+ };
3407
+ responses: {
3408
+ 200: components["responses"]["AssistantOK"];
3409
+ 400: components["responses"]["Error"];
3410
+ 401: components["responses"]["Error"];
3411
+ 402: components["responses"]["Error"];
3412
+ 403: components["responses"]["Error"];
3413
+ 429: components["responses"]["Error"];
3414
+ 503: components["responses"]["Unavailable"];
3415
+ };
3416
+ };
3417
+ gemini: {
3418
+ parameters: {
3419
+ query?: never;
3420
+ header?: never;
3421
+ path?: never;
3422
+ cookie?: never;
3423
+ };
3424
+ requestBody: {
3425
+ content: {
3426
+ /**
3427
+ * @example {
3428
+ * "prompt": "How do heat pumps work in cold climates?"
3429
+ * }
3430
+ */
3431
+ "application/json": components["schemas"]["AssistantRequest"];
3432
+ };
3433
+ };
2666
3434
  responses: {
2667
- 200: components["responses"]["ScholarOK"];
3435
+ 200: components["responses"]["AssistantOK"];
2668
3436
  400: components["responses"]["Error"];
2669
3437
  401: components["responses"]["Error"];
2670
3438
  402: components["responses"]["Error"];
@@ -2673,16 +3441,26 @@ interface operations {
2673
3441
  503: components["responses"]["Unavailable"];
2674
3442
  };
2675
3443
  };
2676
- patents: {
3444
+ copilot: {
2677
3445
  parameters: {
2678
3446
  query?: never;
2679
3447
  header?: never;
2680
3448
  path?: never;
2681
3449
  cookie?: never;
2682
3450
  };
2683
- requestBody: components["requestBodies"]["Search"];
3451
+ requestBody: {
3452
+ content: {
3453
+ /**
3454
+ * @example {
3455
+ * "prompt": "best mattress for side sleepers",
3456
+ * "country": "us"
3457
+ * }
3458
+ */
3459
+ "application/json": components["schemas"]["AssistantRequest"];
3460
+ };
3461
+ };
2684
3462
  responses: {
2685
- 200: components["responses"]["PatentsOK"];
3463
+ 200: components["responses"]["AssistantOK"];
2686
3464
  400: components["responses"]["Error"];
2687
3465
  401: components["responses"]["Error"];
2688
3466
  402: components["responses"]["Error"];
@@ -2691,16 +3469,25 @@ interface operations {
2691
3469
  503: components["responses"]["Unavailable"];
2692
3470
  };
2693
3471
  };
2694
- autocomplete: {
3472
+ aiMode: {
2695
3473
  parameters: {
2696
3474
  query?: never;
2697
3475
  header?: never;
2698
3476
  path?: never;
2699
3477
  cookie?: never;
2700
3478
  };
2701
- requestBody: components["requestBodies"]["Search"];
3479
+ requestBody: {
3480
+ content: {
3481
+ /**
3482
+ * @example {
3483
+ * "prompt": "how to remove a red wine stain from a wool carpet"
3484
+ * }
3485
+ */
3486
+ "application/json": components["schemas"]["AssistantRequest"];
3487
+ };
3488
+ };
2702
3489
  responses: {
2703
- 200: components["responses"]["AutocompleteOK"];
3490
+ 200: components["responses"]["AssistantOK"];
2704
3491
  400: components["responses"]["Error"];
2705
3492
  401: components["responses"]["Error"];
2706
3493
  402: components["responses"]["Error"];
@@ -2709,7 +3496,7 @@ interface operations {
2709
3496
  503: components["responses"]["Unavailable"];
2710
3497
  };
2711
3498
  };
2712
- webpage: {
3499
+ braveAi: {
2713
3500
  parameters: {
2714
3501
  query?: never;
2715
3502
  header?: never;
@@ -2718,11 +3505,16 @@ interface operations {
2718
3505
  };
2719
3506
  requestBody: {
2720
3507
  content: {
2721
- "application/json": components["schemas"]["WebpageRequest"];
3508
+ /**
3509
+ * @example {
3510
+ * "prompt": "best budget noise cancelling headphones under $100"
3511
+ * }
3512
+ */
3513
+ "application/json": components["schemas"]["AssistantRequest"];
2722
3514
  };
2723
3515
  };
2724
3516
  responses: {
2725
- 200: components["responses"]["WebpageOK"];
3517
+ 200: components["responses"]["AssistantOK"];
2726
3518
  400: components["responses"]["Error"];
2727
3519
  401: components["responses"]["Error"];
2728
3520
  402: components["responses"]["Error"];
@@ -2867,6 +3659,203 @@ interface operations {
2867
3659
  429: components["responses"]["Error"];
2868
3660
  };
2869
3661
  };
3662
+ answer: {
3663
+ parameters: {
3664
+ query?: never;
3665
+ header?: never;
3666
+ path?: never;
3667
+ cookie?: never;
3668
+ };
3669
+ requestBody: {
3670
+ content: {
3671
+ /**
3672
+ * @example {
3673
+ * "q": "what is retrieval-augmented generation",
3674
+ * "depth": "standard",
3675
+ * "num_sources": 3
3676
+ * }
3677
+ */
3678
+ "application/json": components["schemas"]["AnswerRequest"];
3679
+ };
3680
+ };
3681
+ responses: {
3682
+ /** @description OK (`text/event-stream` when `stream` is true) */
3683
+ 200: {
3684
+ headers: {
3685
+ "X-Credits-Used": components["headers"]["CreditsUsed"];
3686
+ "X-Credits-Remaining": components["headers"]["CreditsRemaining"];
3687
+ "X-Cost-USD": components["headers"]["CostUSD"];
3688
+ "X-Cache": components["headers"]["Cache"];
3689
+ "X-Latency-Ms": components["headers"]["LatencyMs"];
3690
+ "X-Tokens-Estimate": components["headers"]["TokensEstimate"];
3691
+ [name: string]: unknown;
3692
+ };
3693
+ content: {
3694
+ /**
3695
+ * @example {
3696
+ * "request": {
3697
+ * "endpoint": "answer",
3698
+ * "engine": "google",
3699
+ * "q": "what is retrieval-augmented generation",
3700
+ * "country": "us",
3701
+ * "language": "en",
3702
+ * "num": 10,
3703
+ * "page": 1,
3704
+ * "autocorrect": true,
3705
+ * "device": "desktop",
3706
+ * "include_content": 3,
3707
+ * "depth": "standard",
3708
+ * "num_sources": 3
3709
+ * },
3710
+ * "answer": "Retrieval-augmented generation (RAG) grounds a language model's answer in documents retrieved at query time [1], which reduces hallucinations and keeps answers current [2].",
3711
+ * "citations": [
3712
+ * {
3713
+ * "index": 1,
3714
+ * "title": "Retrieval-augmented generation",
3715
+ * "link": "https://en.wikipedia.org/wiki/Retrieval-augmented_generation",
3716
+ * "domain": "en.wikipedia.org"
3717
+ * },
3718
+ * {
3719
+ * "index": 2,
3720
+ * "title": "What is RAG?",
3721
+ * "link": "https://www.ibm.com/think/topics/retrieval-augmented-generation",
3722
+ * "domain": "ibm.com"
3723
+ * }
3724
+ * ],
3725
+ * "results": [
3726
+ * {
3727
+ * "index": 1,
3728
+ * "title": "Retrieval-augmented generation",
3729
+ * "link": "https://en.wikipedia.org/wiki/Retrieval-augmented_generation",
3730
+ * "domain": "en.wikipedia.org"
3731
+ * },
3732
+ * {
3733
+ * "index": 2,
3734
+ * "title": "What is RAG?",
3735
+ * "link": "https://www.ibm.com/think/topics/retrieval-augmented-generation",
3736
+ * "domain": "ibm.com"
3737
+ * }
3738
+ * ],
3739
+ * "meta": {
3740
+ * "request_id": "req_01J9",
3741
+ * "credits_used": 6,
3742
+ * "credits": {
3743
+ * "search": 4,
3744
+ * "answer": 2
3745
+ * },
3746
+ * "cached": false,
3747
+ * "engine": "google",
3748
+ * "latency_ms": 4410,
3749
+ * "llm": {
3750
+ * "provider": "anthropic",
3751
+ * "model": "claude-haiku-5-5",
3752
+ * "input_tokens": 3120,
3753
+ * "output_tokens": 88
3754
+ * }
3755
+ * }
3756
+ * }
3757
+ */
3758
+ "application/json": components["schemas"]["AnswerResponse"];
3759
+ /**
3760
+ * @example event: results
3761
+ * data: {"request":{"endpoint":"answer","q":"what is retrieval-augmented generation"},"results":[{"index":1,"title":"Retrieval-augmented generation","link":"https://en.wikipedia.org/wiki/Retrieval-augmented_generation","domain":"en.wikipedia.org"}]}
3762
+ *
3763
+ * event: delta
3764
+ * data: {"text":"Retrieval-augmented generation grounds "}
3765
+ *
3766
+ * event: done
3767
+ * data: {"answer":"Retrieval-augmented generation grounds a model's answer in documents retrieved at query time [1].","citations":[{"index":1,"title":"Retrieval-augmented generation","link":"https://en.wikipedia.org/wiki/Retrieval-augmented_generation","domain":"en.wikipedia.org"}],"meta":{"request_id":"req_01J9","credits_used":3,"cached":false}}
3768
+ */
3769
+ "text/event-stream": string;
3770
+ };
3771
+ };
3772
+ 400: components["responses"]["Error"];
3773
+ 401: components["responses"]["Error"];
3774
+ 402: components["responses"]["Error"];
3775
+ 403: components["responses"]["Error"];
3776
+ 429: components["responses"]["Error"];
3777
+ 503: components["responses"]["Unavailable"];
3778
+ };
3779
+ };
3780
+ createResearch: {
3781
+ parameters: {
3782
+ query?: never;
3783
+ header?: never;
3784
+ path?: never;
3785
+ cookie?: never;
3786
+ };
3787
+ requestBody: {
3788
+ content: {
3789
+ /**
3790
+ * @example {
3791
+ * "input": "compare espresso machines under $500 for a small office",
3792
+ * "effort": "standard",
3793
+ * "output_schema": {
3794
+ * "type": "object",
3795
+ * "properties": {
3796
+ * "winner": {
3797
+ * "type": "string"
3798
+ * }
3799
+ * }
3800
+ * }
3801
+ * }
3802
+ */
3803
+ "application/json": components["schemas"]["ResearchRequest"];
3804
+ };
3805
+ };
3806
+ responses: {
3807
+ 202: components["responses"]["TaskAccepted"];
3808
+ 400: components["responses"]["Error"];
3809
+ 401: components["responses"]["Error"];
3810
+ 402: components["responses"]["Error"];
3811
+ 403: components["responses"]["Error"];
3812
+ 429: components["responses"]["Error"];
3813
+ 503: components["responses"]["Unavailable"];
3814
+ };
3815
+ };
3816
+ getResearch: {
3817
+ parameters: {
3818
+ query?: never;
3819
+ header?: never;
3820
+ path: {
3821
+ id: string;
3822
+ };
3823
+ cookie?: never;
3824
+ };
3825
+ requestBody?: never;
3826
+ responses: {
3827
+ /** @description OK */
3828
+ 200: {
3829
+ headers: {
3830
+ [name: string]: unknown;
3831
+ };
3832
+ content: {
3833
+ "application/json": components["schemas"]["ResearchTask"];
3834
+ };
3835
+ };
3836
+ 401: components["responses"]["Error"];
3837
+ 404: components["responses"]["Error"];
3838
+ 429: components["responses"]["Error"];
3839
+ };
3840
+ };
3841
+ cancelResearch: {
3842
+ parameters: {
3843
+ query?: never;
3844
+ header?: never;
3845
+ path: {
3846
+ id: string;
3847
+ };
3848
+ cookie?: never;
3849
+ };
3850
+ requestBody?: never;
3851
+ responses: {
3852
+ 200: components["responses"]["TaskCanceled"];
3853
+ 401: components["responses"]["Error"];
3854
+ 404: components["responses"]["Error"];
3855
+ 409: components["responses"]["Error"];
3856
+ 429: components["responses"]["Error"];
3857
+ };
3858
+ };
2870
3859
  listMonitors: {
2871
3860
  parameters: {
2872
3861
  query?: never;
@@ -3393,6 +4382,28 @@ interface operations {
3393
4382
  };
3394
4383
  };
3395
4384
  };
4385
+ researchCompletedWebhook: {
4386
+ parameters: {
4387
+ query?: never;
4388
+ header?: never;
4389
+ path?: never;
4390
+ cookie?: never;
4391
+ };
4392
+ requestBody: {
4393
+ content: {
4394
+ "application/json": components["schemas"]["TaskCompletedEvent"];
4395
+ };
4396
+ };
4397
+ responses: {
4398
+ /** @description Any 2xx acknowledges the delivery */
4399
+ 200: {
4400
+ headers: {
4401
+ [name: string]: unknown;
4402
+ };
4403
+ content?: never;
4404
+ };
4405
+ };
4406
+ };
3396
4407
  monitorResultsWebhook: {
3397
4408
  parameters: {
3398
4409
  query?: never;
@@ -3455,6 +4466,14 @@ type WebpageParams = Schemas["WebpageRequest"];
3455
4466
  type RankParams = Schemas["RankRequest"];
3456
4467
  type MapParams = Schemas["MapRequest"];
3457
4468
  type ExtractParams = Schemas["ExtractRequest"];
4469
+ /**
4470
+ * Body of `gemini`, `copilot`, `aiMode` and `braveAi`: `prompt` (required), `country`, `language`,
4471
+ * `track` (brands and domains to look for, returned in `mentions`), `include_html`, `format`,
4472
+ * `fields`, `max_age`.
4473
+ */
4474
+ type AssistantParams = Schemas["AssistantRequest"];
4475
+ /** Body of `chatgpt`: like {@link AssistantParams} plus `web_search` (default true), without `language`. */
4476
+ type ChatGPTParams = Schemas["ChatGPTRequest"];
3458
4477
  /** `format` values accepted by the verticals. */
3459
4478
  type Format = NonNullable<SearchParams["format"]>;
3460
4479
  type Meta = Schemas["Meta"];
@@ -3496,6 +4515,27 @@ type MapURL = Schemas["MapURL"];
3496
4515
  type ExtractResult = Schemas["ExtractResult"];
3497
4516
  type ExtractFailure = Schemas["ExtractFailure"];
3498
4517
  type RankMatch = Schemas["RankResponse"]["matches"][number];
4518
+ /** A source an AI answer or report cites with an `[index]` marker. */
4519
+ type Citation = Schemas["Citation"];
4520
+ /**
4521
+ * `include_answer: true` on `search` / `news`: a cited answer over the response's results
4522
+ * (`text` with `[n]` markers). Absent when the model failed (refunded, see `meta.warnings`).
4523
+ */
4524
+ type SearchAnswer = Schemas["SearchAnswer"];
4525
+ /** `meta.llm`: the model behind an AI response and the tokens it used. */
4526
+ type LLMUsage = Schemas["LLMUsage"];
4527
+ /** A source of an AI assistant answer or AI Overview; `cited` when the answer cites it inline. */
4528
+ type AISource = Schemas["AISource"];
4529
+ /** A product an AI assistant showed (price as shown, `extracted_price`, `currency`, merchant…). */
4530
+ type AIProduct = Schemas["AIProduct"];
4531
+ /**
4532
+ * One `track` term checked against an AI answer: `mentioned` (the text names it), `cited` (a cited
4533
+ * source matches it), the matching `sources` / `products` positions and `text_position` (0-1, -1
4534
+ * when the text doesn't name it).
4535
+ */
4536
+ type Mention = Schemas["Mention"];
4537
+ /** `ai_overview` on `search`: Google's AI Overview when the page showed one. */
4538
+ type AIOverview = Schemas["AIOverview"];
3499
4539
  type SearchResponse = Schemas["SearchResponse"];
3500
4540
  type ImagesResponse = Schemas["ImagesResponse"];
3501
4541
  type VideosResponse = Schemas["VideosResponse"];
@@ -3512,6 +4552,14 @@ type WebpageResponse = Schemas["WebpageResponse"];
3512
4552
  type RankResponse = Schemas["RankResponse"];
3513
4553
  type MapResponse = Schemas["MapResponse"];
3514
4554
  type ExtractResponse = Schemas["ExtractResponse"];
4555
+ /**
4556
+ * Returned by `chatgpt`, `gemini`, `copilot`, `aiMode` and `braveAi`: the answer (`text`,
4557
+ * `markdown` with `[n](link)` citations), `sources`, `search_queries`, `products`, `places`,
4558
+ * `related_questions`, `model` where the assistant reports it, and `mentions` with `track`.
4559
+ */
4560
+ type AssistantResponse = Schemas["AssistantResponse"];
4561
+ /** The AI assistant endpoints (also accepted by batches and monitors). */
4562
+ type AssistantEndpoint = "chatgpt" | "gemini" | "copilot" | "ai_mode" | "brave_ai";
3515
4563
  type Account = Schemas["Account"];
3516
4564
  type Status = Schemas["Status"];
3517
4565
  /**
@@ -3523,6 +4571,34 @@ interface CompactResponse {
3523
4571
  meta: Meta;
3524
4572
  [key: string]: unknown;
3525
4573
  }
4574
+ /** Body of `POST /v1/answer` (`stream` is set by `answerStream`). */
4575
+ type AnswerParams = Omit<Schemas["AnswerRequest"], "engine" | "stream"> & {
4576
+ /** Search providers allowed to answer. Default `"google"`. See {@link Engine}. */
4577
+ engine?: Engine;
4578
+ };
4579
+ type AnswerResponse = Schemas["AnswerResponse"];
4580
+ /** A result the answer may cite, numbered as in the prompt (`[index]`). */
4581
+ type AnswerSource = Schemas["AnswerSource"];
4582
+ /** `meta` of an answer: `credits` splits `credits_used` into search and model; `llm` names the model. */
4583
+ type AnswerMeta = Schemas["AnswerMeta"];
4584
+ type AnswerStreamResults = Schemas["AnswerStreamResults"];
4585
+ type AnswerStreamDelta = Schemas["AnswerStreamDelta"];
4586
+ type AnswerStreamDone = Schemas["AnswerStreamDone"];
4587
+ /**
4588
+ * One Server-Sent Event of `answerStream`: `results` first, then `delta` pieces of text,
4589
+ * then `done` with the final answer, citations and meta. A server `error` event is thrown
4590
+ * as a `SerpKiteError` instead of being yielded.
4591
+ */
4592
+ type AnswerStreamEvent = {
4593
+ event: "results";
4594
+ data: AnswerStreamResults;
4595
+ } | {
4596
+ event: "delta";
4597
+ data: AnswerStreamDelta;
4598
+ } | {
4599
+ event: "done";
4600
+ data: AnswerStreamDone;
4601
+ };
3526
4602
  type Batch = Schemas["Batch"];
3527
4603
  type BatchStatus = Batch["status"];
3528
4604
  type BatchEndpoint = Schemas["BatchCreateRequest"]["endpoint"];
@@ -3550,6 +4626,11 @@ type BatchRequestMap = {
3550
4626
  patents: SearchParams;
3551
4627
  autocomplete: SearchParams;
3552
4628
  webpage: WebpageParams;
4629
+ chatgpt: ChatGPTParams;
4630
+ gemini: AssistantParams;
4631
+ copilot: AssistantParams;
4632
+ ai_mode: AssistantParams;
4633
+ brave_ai: AssistantParams;
3553
4634
  };
3554
4635
  /** Body of `POST /v1/batches`. `requests` takes the same fields as the realtime endpoint. */
3555
4636
  type BatchCreateParams = {
@@ -3562,7 +4643,7 @@ type BatchCreateParams = {
3562
4643
  };
3563
4644
  }[BatchEndpoint];
3564
4645
  type TaskStatus = Schemas["TaskStatus"];
3565
- /** The `202` body of `crawl`. */
4646
+ /** The `202` body of `crawl` and `research`. */
3566
4647
  type TaskCreated = Schemas["TaskCreated"];
3567
4648
  type TaskCancelResponse = Schemas["TaskCancelResponse"];
3568
4649
  type TaskError = Schemas["TaskError"];
@@ -3581,9 +4662,30 @@ type CrawlStats = CrawlResult["stats"];
3581
4662
  /** Why a crawl ended (`result.stats.stopped`). */
3582
4663
  type CrawlStopReason = NonNullable<CrawlStats["stopped"]>;
3583
4664
  type CrawlPage = Schemas["CrawlPage"];
4665
+ /**
4666
+ * Body of `POST /v1/research`: `input` (the task in plain words), `effort` (`lite`, `standard`
4667
+ * (default) or `deep`; flat prices at https://serpkite.com/pricing), optional `output_schema`,
4668
+ * locale, domain filters and `webhook_url` (receives `research.completed`).
4669
+ */
4670
+ type ResearchParams = Schemas["ResearchRequest"];
4671
+ type ResearchEffort = NonNullable<ResearchParams["effort"]>;
4672
+ type ResearchResult = Schemas["ResearchResult"];
4673
+ type ResearchSource = Schemas["ResearchSource"];
4674
+ /**
4675
+ * A research task. `result` is set once the report is written (`status: "completed"`); a
4676
+ * failed or canceled task may carry a partial result with only `queries`.
4677
+ */
4678
+ type ResearchTask = Omit<Schemas["ResearchTask"], "result"> & {
4679
+ result?: ResearchResult | null;
4680
+ };
4681
+ /** `progress` of a running research task (round, queries, sources, current step). */
4682
+ type ResearchProgress = NonNullable<Schemas["ResearchTask"]["progress"]>;
3584
4683
  /**
3585
4684
  * Body of `POST /v1/monitors`. `search` and `news` monitors need `q`; `webpage` monitors need
3586
- * `url` (and take only `country` besides) and report the page when its content changes.
4685
+ * `url` (and take only `country` besides) and report the page when its content changes. AI
4686
+ * assistant monitors (`chatgpt`, `gemini`, `copilot`, `ai_mode`, `brave_ai`) need `prompt` and take
4687
+ * `country`, `language` (not chatgpt), `web_search` (chatgpt) and `track`; every run reports the
4688
+ * answer as a {@link MonitorAnswer}.
3587
4689
  * `metadata` is your own JSON object (at most 2 KB), echoed on the monitor and its webhooks.
3588
4690
  * `webhook_url` is optional: without one, new results are read from the run history
3589
4691
  * (`monitors.runs`). `active: false` creates the monitor paused.
@@ -3602,7 +4704,10 @@ type MonitorUpdateParams = Omit<Schemas["MonitorUpdateRequest"], "engine"> & {
3602
4704
  engine?: Engine;
3603
4705
  };
3604
4706
  type Monitor = Schemas["Monitor"];
3605
- /** What a monitor watches: a `search`, `news` search, or a `webpage` for content changes. */
4707
+ /**
4708
+ * What a monitor watches: a `search`, `news` search, a `webpage` for content changes, or an AI
4709
+ * assistant's answer to a prompt (`chatgpt`, `gemini`, `copilot`, `ai_mode`, `brave_ai`).
4710
+ */
3606
4711
  type MonitorEndpoint = Monitor["endpoint"];
3607
4712
  /** Your own JSON object on a monitor (at most 2 KB), echoed in `monitor.results`. */
3608
4713
  type MonitorMetadata = NonNullable<Monitor["metadata"]>;
@@ -3611,13 +4716,19 @@ type MonitorMetadata = NonNullable<Monitor["metadata"]>;
3611
4716
  * the page when first seen (`change: "new"`) or when its content changed (`"changed"`).
3612
4717
  */
3613
4718
  type MonitorPageChange = Schemas["MonitorPageChange"];
4719
+ /**
4720
+ * The result item of an AI assistant monitor: one per run (every run reports the answer), with
4721
+ * `new_sources` (source links not seen in earlier runs) and, with `track`, `mentions`.
4722
+ */
4723
+ type MonitorAnswer = Schemas["MonitorAnswer"];
3614
4724
  /** `last_status` of a monitor; `"paused"` after 10 failed runs in a row. */
3615
4725
  type MonitorStatus = NonNullable<Monitor["last_status"]>;
3616
4726
  type MonitorList = Schemas["MonitorList"];
3617
4727
  type MonitorSearch = Schemas["MonitorSearch"];
3618
4728
  /**
3619
4729
  * One run of a monitor. `results` holds the new results (null when none, or after 24 hours):
3620
- * `OrganicResult`-shaped for search, `NewsResult` for news, {@link MonitorPageChange} for webpage.
4730
+ * `OrganicResult`-shaped for search, `NewsResult` for news, {@link MonitorPageChange} for webpage,
4731
+ * one {@link MonitorAnswer} for AI assistants.
3621
4732
  */
3622
4733
  type MonitorRun = Schemas["MonitorRun"];
3623
4734
  /** A page of runs, newest first. Pass `next_before` as `before` for the next page. */
@@ -3629,18 +4740,26 @@ type BatchCompletedEvent = Omit<Batch, "poll_url" | "webhook_url" | "webhook_sta
3629
4740
  event: "batch.completed";
3630
4741
  };
3631
4742
  /**
3632
- * Body of `crawl.completed`. When the result is over 4 MB, `result` is null and
4743
+ * Body of `crawl.completed` and `research.completed` (`kind` says which; `result` is a
4744
+ * `CrawlResult` or `ResearchResult`). When the result is over 4 MB, `result` is null and
3633
4745
  * `result_omitted` is true: fetch the task from `poll_url`.
3634
4746
  */
3635
4747
  type TaskCompletedEvent = Schemas["TaskCompletedEvent"];
4748
+ /** Body of `research.completed`: a {@link TaskCompletedEvent} whose `result` is a `ResearchResult`. */
4749
+ type ResearchCompletedEvent = Omit<TaskCompletedEvent, "event" | "kind" | "result"> & {
4750
+ event: "research.completed";
4751
+ kind: "research";
4752
+ result?: ResearchResult | null;
4753
+ };
3636
4754
  /**
3637
4755
  * Body of `monitor.results`. `run_id` is also the `X-SerpKite-Delivery` header (dedupe retries
3638
4756
  * on it). Carries the monitor's `metadata`, and `url` for webpage monitors (whose `new_results`
3639
- * are {@link MonitorPageChange} items and `q` is empty).
4757
+ * are {@link MonitorPageChange} items and `q` is empty). AI assistant monitors send `prompt`
4758
+ * instead of `q` and one {@link MonitorAnswer} in `new_results`.
3640
4759
  */
3641
4760
  type MonitorResultsEvent = Schemas["MonitorResultsEvent"];
3642
4761
  /** `X-SerpKite-Event` values. Plain strings stay accepted for events added later. */
3643
- type WebhookEventType = "batch.completed" | "crawl.completed" | "monitor.results" | (string & {});
4762
+ type WebhookEventType = "batch.completed" | "crawl.completed" | "research.completed" | "monitor.results" | (string & {});
3644
4763
  /** A verified webhook delivery, from `parseWebhook`. */
3645
4764
  type WebhookEvent = {
3646
4765
  type: "batch.completed";
@@ -3650,13 +4769,17 @@ type WebhookEvent = {
3650
4769
  type: "crawl.completed";
3651
4770
  deliveryId: string | undefined;
3652
4771
  data: TaskCompletedEvent;
4772
+ } | {
4773
+ type: "research.completed";
4774
+ deliveryId: string | undefined;
4775
+ data: ResearchCompletedEvent;
3653
4776
  } | {
3654
4777
  type: "monitor.results";
3655
4778
  deliveryId: string | undefined;
3656
4779
  data: MonitorResultsEvent;
3657
4780
  };
3658
4781
 
3659
- declare const VERSION = "0.6.0";
4782
+ declare const VERSION = "0.8.0";
3660
4783
  declare const DEFAULT_BASE_URL = "https://api.serpkite.com";
3661
4784
  interface SerpKiteOptions {
3662
4785
  /** API key (`skt_live_…`). Defaults to the `SERPKITE_API_KEY` environment variable. */
@@ -3707,8 +4830,9 @@ interface BatchCreateOptions extends RequestOptions {
3707
4830
  }
3708
4831
  interface WaitOptions {
3709
4832
  /**
3710
- * Give up after this many milliseconds. Default 600000 (10 minutes) for batches and
3711
- * 2100000 (35 minutes) for `waitForCrawl`: a crawl runs for up to 30 minutes.
4833
+ * Give up after this many milliseconds. Default 600000 (10 minutes) for batches,
4834
+ * 2100000 (35 minutes) for `waitForCrawl` (a crawl runs for up to 30 minutes) and
4835
+ * 900000 (15 minutes) for `waitResearch`.
3712
4836
  */
3713
4837
  timeoutMs?: number;
3714
4838
  /** First delay between polls. Default 1000. Grows 1.5× per poll. */
@@ -3731,6 +4855,8 @@ interface VerticalMethod<P, R> {
3731
4855
  (params: P, options?: RequestOptions): Promise<R | CompactResponse | string>;
3732
4856
  }
3733
4857
  type Method = "GET" | "POST" | "PATCH" | "DELETE";
4858
+ /** Minimum per-attempt timeout of the AI assistant methods: answers take 10-90 s. */
4859
+ declare const ASSISTANT_TIMEOUT_MS = 120000;
3734
4860
  interface Call {
3735
4861
  method: Method;
3736
4862
  path: string;
@@ -3757,6 +4883,8 @@ declare class SerpKite {
3757
4883
  related_searches: components["schemas"]["RelatedSearch"][];
3758
4884
  top_stories?: components["schemas"]["NewsResult"][];
3759
4885
  places?: components["schemas"]["PlaceResult"][];
4886
+ answer?: components["schemas"]["SearchAnswer"];
4887
+ ai_overview?: components["schemas"]["AIOverview"];
3760
4888
  meta: components["schemas"]["Meta"];
3761
4889
  }>;
3762
4890
  /** Google Images. */
@@ -3775,6 +4903,7 @@ declare class SerpKite {
3775
4903
  readonly news: VerticalMethod<SearchParams, {
3776
4904
  request: components["schemas"]["RequestEcho"];
3777
4905
  results: components["schemas"]["NewsResult"][];
4906
+ answer?: components["schemas"]["SearchAnswer"];
3778
4907
  meta: components["schemas"]["Meta"];
3779
4908
  }>;
3780
4909
  /**
@@ -3867,12 +4996,141 @@ declare class SerpKite {
3867
4996
  image_links?: string[];
3868
4997
  meta: components["schemas"]["Meta"];
3869
4998
  }>;
4999
+ /**
5000
+ * Ask ChatGPT as a logged-out user: the answer (`text`, `markdown`), cited `sources`,
5001
+ * `search_queries`, `products`, `places` and the guest `model`. `web_search` (default true)
5002
+ * makes it search the web; `country` asks from an exit in that country. `track` returns
5003
+ * `mentions` of your brands and domains. 5 credits.
5004
+ */
5005
+ readonly chatgpt: VerticalMethod<{
5006
+ prompt: string;
5007
+ web_search?: boolean;
5008
+ country?: string;
5009
+ track?: components["schemas"]["TrackList"];
5010
+ include_html?: boolean;
5011
+ format?: "json" | "markdown" | "compact";
5012
+ fields?: string;
5013
+ max_age?: number;
5014
+ }, {
5015
+ request: components["schemas"]["AssistantEcho"];
5016
+ text: string;
5017
+ markdown: string;
5018
+ html?: string;
5019
+ model?: string;
5020
+ sources: components["schemas"]["AISource"][];
5021
+ search_queries: string[];
5022
+ products: components["schemas"]["AIProduct"][];
5023
+ places?: components["schemas"]["PlaceResult"][];
5024
+ related_questions?: string[];
5025
+ mentions?: components["schemas"]["Mention"][];
5026
+ meta: components["schemas"]["Meta"];
5027
+ }>;
5028
+ /** Ask Google Gemini as a logged-out user: the answer with the sources it grounded on. 5 credits. */
5029
+ readonly gemini: VerticalMethod<{
5030
+ prompt: string;
5031
+ country?: string;
5032
+ language?: string;
5033
+ track?: components["schemas"]["TrackList"];
5034
+ include_html?: boolean;
5035
+ format?: "json" | "markdown" | "compact";
5036
+ fields?: string;
5037
+ max_age?: number;
5038
+ }, {
5039
+ request: components["schemas"]["AssistantEcho"];
5040
+ text: string;
5041
+ markdown: string;
5042
+ html?: string;
5043
+ model?: string;
5044
+ sources: components["schemas"]["AISource"][];
5045
+ search_queries: string[];
5046
+ products: components["schemas"]["AIProduct"][];
5047
+ places?: components["schemas"]["PlaceResult"][];
5048
+ related_questions?: string[];
5049
+ mentions?: components["schemas"]["Mention"][];
5050
+ meta: components["schemas"]["Meta"];
5051
+ }>;
5052
+ /** Microsoft Copilot Search on Bing: the answer, cited sources and products. 3 credits. */
5053
+ readonly copilot: VerticalMethod<{
5054
+ prompt: string;
5055
+ country?: string;
5056
+ language?: string;
5057
+ track?: components["schemas"]["TrackList"];
5058
+ include_html?: boolean;
5059
+ format?: "json" | "markdown" | "compact";
5060
+ fields?: string;
5061
+ max_age?: number;
5062
+ }, {
5063
+ request: components["schemas"]["AssistantEcho"];
5064
+ text: string;
5065
+ markdown: string;
5066
+ html?: string;
5067
+ model?: string;
5068
+ sources: components["schemas"]["AISource"][];
5069
+ search_queries: string[];
5070
+ products: components["schemas"]["AIProduct"][];
5071
+ places?: components["schemas"]["PlaceResult"][];
5072
+ related_questions?: string[];
5073
+ mentions?: components["schemas"]["Mention"][];
5074
+ meta: components["schemas"]["Meta"];
5075
+ }>;
5076
+ /** Google AI Mode: the answer, cited sources and products. 3 credits. */
5077
+ readonly aiMode: VerticalMethod<{
5078
+ prompt: string;
5079
+ country?: string;
5080
+ language?: string;
5081
+ track?: components["schemas"]["TrackList"];
5082
+ include_html?: boolean;
5083
+ format?: "json" | "markdown" | "compact";
5084
+ fields?: string;
5085
+ max_age?: number;
5086
+ }, {
5087
+ request: components["schemas"]["AssistantEcho"];
5088
+ text: string;
5089
+ markdown: string;
5090
+ html?: string;
5091
+ model?: string;
5092
+ sources: components["schemas"]["AISource"][];
5093
+ search_queries: string[];
5094
+ products: components["schemas"]["AIProduct"][];
5095
+ places?: components["schemas"]["PlaceResult"][];
5096
+ related_questions?: string[];
5097
+ mentions?: components["schemas"]["Mention"][];
5098
+ meta: components["schemas"]["Meta"];
5099
+ }>;
5100
+ /** Brave Search's AI answer: cited sources, the searches it ran and products. 2 credits. */
5101
+ readonly braveAi: VerticalMethod<{
5102
+ prompt: string;
5103
+ country?: string;
5104
+ language?: string;
5105
+ track?: components["schemas"]["TrackList"];
5106
+ include_html?: boolean;
5107
+ format?: "json" | "markdown" | "compact";
5108
+ fields?: string;
5109
+ max_age?: number;
5110
+ }, {
5111
+ request: components["schemas"]["AssistantEcho"];
5112
+ text: string;
5113
+ markdown: string;
5114
+ html?: string;
5115
+ model?: string;
5116
+ sources: components["schemas"]["AISource"][];
5117
+ search_queries: string[];
5118
+ products: components["schemas"]["AIProduct"][];
5119
+ places?: components["schemas"]["PlaceResult"][];
5120
+ related_questions?: string[];
5121
+ mentions?: components["schemas"]["Mention"][];
5122
+ meta: components["schemas"]["Meta"];
5123
+ }>;
3870
5124
  /** Position of `domain` for keyword `q` in the top `num` results (default 100). */
3871
5125
  rank(params: RankParams, options?: RequestOptions): Promise<RankResponse>;
3872
5126
  /**
3873
5127
  * Read up to 20 URLs (HTML or PDF) as Markdown, text or HTML in one call, with optional
3874
5128
  * query-ranked `highlights` (BM25), `include_links` and `include_images`. 1 credit per URL
3875
5129
  * that comes back (0.5 from cache); URLs that fail are listed in `failed` and cost nothing.
5130
+ * `summary: true` adds an AI summary of each page and `output_schema` (a JSON Schema, guided
5131
+ * by an optional `prompt`) returns each page's data as JSON in `output`, each at an extra
5132
+ * per-page price (https://serpkite.com/pricing); a page whose model step failed has
5133
+ * `summary_error` / `output_error` instead and isn't charged for it.
3876
5134
  */
3877
5135
  extract(params: ExtractParams, options?: RequestOptions): Promise<ExtractResponse>;
3878
5136
  /**
@@ -3884,6 +5142,29 @@ declare class SerpKite {
3884
5142
  map(params: MapParams, options?: RequestOptions): Promise<MapResponse>;
3885
5143
  /** Balance, limits and this month's usage for the key's account. */
3886
5144
  account(options?: RequestOptions): Promise<Account>;
5145
+ /**
5146
+ * A cited answer grounded on live Google results: Markdown with `[n]` markers in `answer`,
5147
+ * the cited sources in `citations`. `depth: "fast"` answers from the result page;
5148
+ * `"standard"` (default) also reads the top `num_sources` pages and costs more
5149
+ * (https://serpkite.com/pricing; `meta.credits` splits search and model). With
5150
+ * `output_schema` the answer is a JSON value in `output`.
5151
+ * When the model fails the call throws `ai_unavailable` (503) and the model part is refunded;
5152
+ * a search with nothing to answer from returns `answer: null` and a `meta.warnings` entry.
5153
+ */
5154
+ answer(params: AnswerParams, options?: RequestOptions): Promise<AnswerResponse>;
5155
+ /**
5156
+ * Streams an answer as Server-Sent Events: `results` first, then `delta` text pieces,
5157
+ * then `done` (final answer, citations, meta). A server `error` event is thrown as a
5158
+ * `SerpKiteError` (`ai_unavailable`). Breaking out of the loop closes the connection
5159
+ * (the model part is then not charged). Can't be combined with `output_schema`.
5160
+ *
5161
+ * ```ts
5162
+ * for await (const ev of sk.answerStream({ q: "what is retrieval-augmented generation" })) {
5163
+ * if (ev.event === "delta") process.stdout.write(ev.data.text);
5164
+ * }
5165
+ * ```
5166
+ */
5167
+ answerStream(params: AnswerParams, options?: RequestOptions): AsyncIterable<AnswerStreamEvent>;
3887
5168
  /**
3888
5169
  * Starts an async crawl of one site and returns the queued task (`202`). 1 credit per page
3889
5170
  * read (0.5 from cache); `limit` credits (up to 1000 pages, `max_depth` up to 10) are
@@ -3906,6 +5187,33 @@ declare class SerpKite {
3906
5187
  waitForCrawl(idOrTask: string | {
3907
5188
  id: string;
3908
5189
  }, options?: WaitOptions): Promise<CrawlTask>;
5190
+ /**
5191
+ * Starts an async research task: the model plans searches, reads the sources and writes a
5192
+ * cited Markdown report (`result.report`). `effort` (`lite`, `standard` (default), `deep`)
5193
+ * sets how much is searched and read; its flat price (https://serpkite.com/pricing) is
5194
+ * reserved up front and charged only when the report is written (a canceled task is charged
5195
+ * for the searches already run). With
5196
+ * `output_schema` the report is also returned as JSON in `result.output`. Poll with
5197
+ * `getResearch` / `waitResearch` or receive the signed `research.completed` webhook.
5198
+ * Only retried on 429, so a lost response never starts (and reserves) a second task.
5199
+ */
5200
+ research(params: ResearchParams, options?: RequestOptions): Promise<TaskCreated>;
5201
+ /** Polls a research task (`progress` while it runs; results are kept for 24 hours). */
5202
+ getResearch(id: string, options?: RequestOptions): Promise<ResearchTask>;
5203
+ /**
5204
+ * Cancels a research task: refunded if still queued, else stops at its next round and is
5205
+ * charged for the searches run.
5206
+ */
5207
+ cancelResearch(id: string, options?: RequestOptions): Promise<TaskCancelResponse>;
5208
+ /**
5209
+ * Polls until the research task is `completed`, `failed` or `canceled` and returns it (a
5210
+ * failed task is returned, not thrown; check `status` and `error`). The report is in
5211
+ * `result.report`. Accepts an id or the task returned by `research`. Default timeout
5212
+ * 15 minutes.
5213
+ */
5214
+ waitResearch(idOrTask: string | {
5215
+ id: string;
5216
+ }, options?: WaitOptions): Promise<ResearchTask>;
3909
5217
  readonly monitors: {
3910
5218
  /**
3911
5219
  * Saves a `search` or `news` request (`q`) that runs on a schedule (hourly to monthly) and
@@ -3914,7 +5222,9 @@ declare class SerpKite {
3914
5222
  * and reports it (`MonitorPageChange`) when its content changes. `metadata` (your JSON
3915
5223
  * object, at most 2 KB) is echoed on the monitor and in its webhooks. Without a
3916
5224
  * `webhook_url`, read new results from `monitors.runs`. `active: false`
3917
- * creates it paused. A monitor pauses itself after 10 failed runs in a row
5225
+ * creates it paused. With an AI assistant `endpoint` (`chatgpt`, `gemini`, `copilot`,
5226
+ * `ai_mode`, `brave_ai`) and a `prompt` every run reports the answer (`MonitorAnswer`:
5227
+ * sources, `new_sources`, `mentions` with `track`). A monitor pauses itself after 10 failed runs in a row
3918
5228
  * (`last_status: "paused"`); `update(id, { active: true })` resumes it. Each run costs
3919
5229
  * what its search costs. Only retried on 429.
3920
5230
  */
@@ -4022,7 +5332,7 @@ interface VerifyWebhookOptions {
4022
5332
  }
4023
5333
  type HeaderSource = Headers | Record<string, string | string[] | undefined>;
4024
5334
  /**
4025
- * Checks a webhook delivery (any event: `batch.completed`, `crawl.completed`,
5335
+ * Checks a webhook delivery (any event: `batch.completed`, `crawl.completed`, `research.completed`,
4026
5336
  * `monitor.results`): `X-SerpKite-Signature` must be
4027
5337
  * `v1=<hex HMAC-SHA256(secret, "<X-SerpKite-Timestamp>.<raw body>")>` and the
4028
5338
  * timestamp recent. Pass the raw request body exactly as received (not
@@ -4037,7 +5347,7 @@ declare function verifyWebhook(secret: string, payload: string | Uint8Array, hea
4037
5347
  * Verifies a delivery (see {@link verifyWebhook}) and returns it typed by its
4038
5348
  * `X-SerpKite-Event` header. `deliveryId` is `X-SerpKite-Delivery` (for
4039
5349
  * `monitor.results` it equals `data.run_id`): use it to deduplicate retries. A
4040
- * `crawl.completed` result over 4 MB arrives as `result: null` with
5350
+ * `crawl.completed` or `research.completed` result over 4 MB arrives as `result: null` with
4041
5351
  * `result_omitted: true`; fetch it from `data.poll_url`. Throws a
4042
5352
  * `SerpKiteError` with code `invalid_signature` when the signature or timestamp
4043
5353
  * doesn't check out.
@@ -4049,4 +5359,4 @@ declare function verifyWebhook(secret: string, payload: string | Uint8Array, hea
4049
5359
  */
4050
5360
  declare function parseWebhook(secret: string, payload: string | Uint8Array, headers: HeaderSource, options?: VerifyWebhookOptions): Promise<WebhookEvent>;
4051
5361
 
4052
- export { type Account, type AnswerBox, type AutocompleteResponse, type Batch, type BatchCompletedEvent, type BatchCreateEntry, type BatchCreateError, type BatchCreateOptions, type BatchCreateParams, type BatchCreateResponse, type BatchEndpoint, type BatchStatus, type CompactResponse, type CrawlPage, type CrawlParams, type CrawlResult, type CrawlSitemapMode, type CrawlStats, type CrawlStopReason, type CrawlTask, DEFAULT_BASE_URL, type DomainList, type Engine, type ErrorBody, type ExtractFailure, type ExtractParams, type ExtractResponse, type ExtractResult, type Format, type Highlight, type HoursInterval, type ImageResult, type ImagesResponse, type KnowledgeGraph, type MapParams, type MapResponse, type MapURL, type MapsResponse, type Meta, type Monitor, type MonitorCreateParams, type MonitorEndpoint, type MonitorList, type MonitorMetadata, type MonitorPageChange, type MonitorResultsEvent, type MonitorRun, type MonitorRunList, type MonitorRunsParams, type MonitorSearch, type MonitorStatus, type MonitorUpdateParams, type NewsResponse, type NewsResult, type OrganicResult, type PageLink, type PageMetadata, type PatentResult, type PatentsResponse, type PeopleAlsoAsk, type PlaceParams, type PlacePhoto, type PlaceResult, type PlacesResponse, type Provider, type RankMatch, type RankParams, type RankResponse, type RelatedSearch, type RequestEcho, type RequestOptions, type ResponseInfo, type ReviewResult, type ReviewsParams, type ReviewsResponse, type RouteOutcome, type RouteStep, type ScholarResponse, type ScholarResult, type SearchParams, type SearchResponse, SerpKite, SerpKiteError, type SerpKiteOptions, type ShoppingResponse, type ShoppingResult, type Sitelink, type Status, type Suggestion, type TaskCancelResponse, type TaskCompletedEvent, type TaskCreated, type TaskError, type TaskStatus, VERSION, type VerifyWebhookOptions, type VerticalMethod, type VideoResult, type VideosResponse, type WaitOptions, type WebhookEvent, type WebhookEventType, type WebpageParams, type WebpageResponse, type WeeklyHours, type components, isBatchError, type operations, parseRetryAfter, parseWebhook, type paths, verifyWebhook };
5362
+ export { type AIOverview, type AIProduct, type AISource, ASSISTANT_TIMEOUT_MS, type Account, type AnswerBox, type AnswerMeta, type AnswerParams, type AnswerResponse, type AnswerSource, type AnswerStreamDelta, type AnswerStreamDone, type AnswerStreamEvent, type AnswerStreamResults, type AssistantEndpoint, type AssistantParams, type AssistantResponse, type AutocompleteResponse, type Batch, type BatchCompletedEvent, type BatchCreateEntry, type BatchCreateError, type BatchCreateOptions, type BatchCreateParams, type BatchCreateResponse, type BatchEndpoint, type BatchStatus, type ChatGPTParams, type Citation, type CompactResponse, type CrawlPage, type CrawlParams, type CrawlResult, type CrawlSitemapMode, type CrawlStats, type CrawlStopReason, type CrawlTask, DEFAULT_BASE_URL, type DomainList, type Engine, type ErrorBody, type ExtractFailure, type ExtractParams, type ExtractResponse, type ExtractResult, type Format, type Highlight, type HoursInterval, type ImageResult, type ImagesResponse, type KnowledgeGraph, type LLMUsage, type MapParams, type MapResponse, type MapURL, type MapsResponse, type Mention, type Meta, type Monitor, type MonitorAnswer, type MonitorCreateParams, type MonitorEndpoint, type MonitorList, type MonitorMetadata, type MonitorPageChange, type MonitorResultsEvent, type MonitorRun, type MonitorRunList, type MonitorRunsParams, type MonitorSearch, type MonitorStatus, type MonitorUpdateParams, type NewsResponse, type NewsResult, type OrganicResult, type PageLink, type PageMetadata, type PatentResult, type PatentsResponse, type PeopleAlsoAsk, type PlaceParams, type PlacePhoto, type PlaceResult, type PlacesResponse, type Provider, type RankMatch, type RankParams, type RankResponse, type RelatedSearch, type RequestEcho, type RequestOptions, type ResearchCompletedEvent, type ResearchEffort, type ResearchParams, type ResearchProgress, type ResearchResult, type ResearchSource, type ResearchTask, type ResponseInfo, type ReviewResult, type ReviewsParams, type ReviewsResponse, type RouteOutcome, type RouteStep, type ScholarResponse, type ScholarResult, type SearchAnswer, type SearchParams, type SearchResponse, SerpKite, SerpKiteError, type SerpKiteOptions, type ShoppingResponse, type ShoppingResult, type Sitelink, type Status, type Suggestion, type TaskCancelResponse, type TaskCompletedEvent, type TaskCreated, type TaskError, type TaskStatus, VERSION, type VerifyWebhookOptions, type VerticalMethod, type VideoResult, type VideosResponse, type WaitOptions, type WebhookEvent, type WebhookEventType, type WebpageParams, type WebpageResponse, type WeeklyHours, type components, isBatchError, type operations, parseRetryAfter, parseWebhook, type paths, verifyWebhook };