Repository navigation
Expand file tree
/
Copy pathperplexityapi.txt
More file actions
620 lines (616 loc) · 22.7 KB
/
Copy pathperplexityapi.txt
File metadata and controls
620 lines (616 loc) · 22.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
# Chat Completions
> Generates a model's response for the given chat conversation.
## OpenAPI
````yaml post /chat/completions
paths:
path: /chat/completions
method: post
servers:
- url: https://api.perplexity.ai
request:
security:
- title: HTTPBearer
parameters:
query: {}
header:
Authorization:
type: http
scheme: bearer
cookie: {}
parameters:
path: {}
query: {}
header: {}
cookie: {}
body:
application/json:
schemaArray:
- type: object
properties:
model:
allOf:
- title: Model
type: string
description: >-
The name of the model that will complete your prompt.
Refer to [Supported
Models](https://docs.perplexity.ai/guides/model-cards) to
find all the models offered.
example: sonar
messages:
allOf:
- title: Messages
type: array
description: A list of messages comprising the conversation so far.
items:
$ref: '#/components/schemas/ChatCompletionsMessage'
example:
- role: system
content: Be precise and concise.
- role: user
content: How many stars are there in our galaxy?
search_mode:
allOf:
- title: Search Mode
type: string
enum:
- academic
- web
default: web
description: >-
Controls the search mode used for the request. When set to
'academic', results will prioritize scholarly sources like
peer-reviewed papers and academic journals. More
information about this
[here](https://docs.perplexity.ai/guides/academic-filter-guide).
reasoning_effort:
allOf:
- title: Reasoning Effort
type: string
enum:
- low
- medium
- high
default: medium
description: >-
Controls how much computational effort the AI dedicates to
each query for deep research models. 'low' provides
faster, simpler answers with reduced token usage, 'medium'
offers a balanced approach, and 'high' delivers deeper,
more thorough responses with increased token usage. This
parameter directly impacts the amount of reasoning tokens
consumed. **WARNING: This parameter is ONLY applicable for
sonar-deep-research.**
max_tokens:
allOf:
- title: Max Tokens
type: integer
description: >-
The maximum number of completion tokens returned by the
API. Controls the length of the model's response. If the
response would exceed this limit, it will be truncated.
Higher values allow for longer responses but may increase
processing time and costs.
temperature:
allOf:
- title: Temperature
type: number
default: 0.2
description: >-
The amount of randomness in the response, valued between 0
and 2. Lower values (e.g., 0.1) make the output more
focused, deterministic, and less creative. Higher values
(e.g., 1.5) make the output more random and creative. Use
lower values for factual/information retrieval tasks and
higher values for creative applications.
minimum: 0
maximum: 2
exclusiveMaximum: true
top_p:
allOf:
- title: Top P
type: number
default: 0.9
description: >-
The nucleus sampling threshold, valued between 0 and 1.
Controls the diversity of generated text by considering
only the tokens whose cumulative probability exceeds the
top_p value. Lower values (e.g., 0.5) make the output more
focused and deterministic, while higher values (e.g.,
0.95) allow for more diverse outputs. Often used as an
alternative to temperature.
search_domain_filter:
allOf:
- title: Search Domain Filter
type: array
description: >-
A list of domains to limit search results to. Currently
limited to 10 domains for Allowlisting and Denylisting.
For Denylisting, add a `-` at the beginning of the domain
string. More information about this
[here](https://docs.perplexity.ai/guides/search-domain-filters).
return_images:
allOf:
- title: Return Images
type: boolean
default: false
description: Determines whether search results should include images.
return_related_questions:
allOf:
- title: Return Related Questions
type: boolean
default: false
description: Determines whether related questions should be returned.
search_recency_filter:
allOf:
- title: Recency Filter
type: string
description: >-
Filters search results based on time (e.g., 'week',
'day').
search_after_date_filter:
allOf:
- title: Search After Date Filter
type: string
description: >-
Filters search results to only include content published
after this date. Format should be %m/%d/%Y (e.g. 3/1/2025)
search_before_date_filter:
allOf:
- title: Search Before Date Filter
type: string
description: >-
Filters search results to only include content published
before this date. Format should be %m/%d/%Y (e.g.
3/1/2025)
last_updated_after_filter:
allOf:
- title: Last Updated After Filter
type: string
description: >-
Filters search results to only include content last
updated after this date. Format should be %m/%d/%Y (e.g.
3/1/2025)
last_updated_before_filter:
allOf:
- title: Last Updated Before Filter
type: string
description: >-
Filters search results to only include content last
updated before this date. Format should be %m/%d/%Y (e.g.
3/1/2025)
top_k:
allOf:
- title: Top K
type: number
default: 0
description: >-
The number of tokens to keep for top-k filtering. Limits
the model to consider only the k most likely next tokens
at each step. Lower values (e.g., 10) make the output more
focused and deterministic, while higher values allow for
more diverse outputs. A value of 0 disables this filter.
Often used in conjunction with top_p to control output
randomness.
stream:
allOf:
- title: Streaming
type: boolean
default: false
description: Determines whether to stream the response incrementally.
presence_penalty:
allOf:
- title: Presence Penalty
type: number
default: 0
description: >-
Positive values increase the likelihood of discussing new
topics. Applies a penalty to tokens that have already
appeared in the text, encouraging the model to talk about
new concepts. Values typically range from 0 (no penalty)
to 2.0 (strong penalty). Higher values reduce repetition
but may lead to more off-topic text.
frequency_penalty:
allOf:
- title: Frequency Penalty
type: number
default: 0
description: >-
Decreases likelihood of repetition based on prior
frequency. Applies a penalty to tokens based on how
frequently they've appeared in the text so far. Values
typically range from 0 (no penalty) to 2.0 (strong
penalty). Higher values (e.g., 1.5) reduce repetition of
the same words and phrases. Useful for preventing the
model from getting stuck in loops.
response_format:
allOf:
- title: Response Format
type: object
description: Enables structured JSON output formatting.
web_search_options:
allOf:
- title: Web Search Options
type: object
description: Configuration for using web search in model responses.
properties:
search_context_size:
title: Search Context Size
type: string
default: low
enum:
- low
- medium
- high
description: >-
Determines how much search context is retrieved for
the model. Options are: `low` (minimizes context for
cost savings but less comprehensive answers), `medium`
(balanced approach suitable for most queries), and
`high` (maximizes context for comprehensive answers
but at higher cost).
user_location:
title: Location of the user.
type: object
description: >-
To refine search results based on geography, you can
specify an approximate user location.
properties:
latitude:
title: Latitude
type: number
description: The latitude of the user's location.
longitude:
title: Longitude
type: number
description: The longitude of the user's location.
country:
title: Country
type: string
description: >-
The two letter ISO country code of the user's
location.
example:
search_context_size: high
required: true
title: ChatCompletionsRequest
refIdentifier: '#/components/schemas/ChatCompletionsRequest'
requiredProperties:
- model
- messages
examples:
example:
value:
model: sonar
messages:
- role: system
content: Be precise and concise.
- role: user
content: How many stars are there in our galaxy?
search_mode: web
reasoning_effort: medium
max_tokens: 123
temperature: 0.2
top_p: 0.9
search_domain_filter:
- <any>
return_images: false
return_related_questions: false
search_recency_filter: <string>
search_after_date_filter: <string>
search_before_date_filter: <string>
last_updated_after_filter: <string>
last_updated_before_filter: <string>
top_k: 0
stream: false
presence_penalty: 0
frequency_penalty: 0
response_format: {}
web_search_options:
search_context_size: high
response:
'200':
application/json:
schemaArray:
- type: object
properties:
id:
allOf:
- title: ID
type: string
description: A unique identifier for the chat completion.
model:
allOf:
- title: Model
type: string
description: The model that generated the response.
created:
allOf:
- title: Created Timestamp
type: integer
description: >-
The Unix timestamp (in seconds) of when the chat
completion was created.
usage:
allOf:
- $ref: '#/components/schemas/UsageInfo'
object:
allOf:
- title: Object Type
type: string
default: chat.completion
description: The type of object, which is always `chat.completion`.
choices:
allOf:
- title: Choices
type: array
items:
$ref: '#/components/schemas/ChatCompletionsChoice'
description: >-
A list of chat completion choices. Can be more than one if
`n` is greater than 1.
citations:
allOf:
- title: Citations
type: array
items:
type: string
nullable: true
description: A list of citation sources for the response.
search_results:
allOf:
- title: Search Results
type: array
items:
$ref: '#/components/schemas/ApiPublicSearchResult'
nullable: true
description: A list of search results related to the response.
title: ChatCompletionsResponseJson
refIdentifier: '#/components/schemas/ChatCompletionsResponseJson'
requiredProperties:
- id
- model
- created
- usage
- object
- choices
examples:
example:
value:
id: <string>
model: <string>
created: 123
usage:
prompt_tokens: 123
completion_tokens: 123
total_tokens: 123
search_context_size: <string>
citation_tokens: 123
num_search_queries: 123
reasoning_tokens: 123
object: chat.completion
choices:
- index: 123
finish_reason: stop
message:
content: <string>
role: system
citations:
- <string>
search_results:
- title: <string>
url: <string>
date: '2023-12-25'
description: OK
text/event-stream:
schemaArray:
- type: object
properties:
id:
allOf:
- title: ID
type: string
description: A unique identifier for the chat completion chunk.
model:
allOf:
- title: Model
type: string
description: The model that generated the response.
created:
allOf:
- title: Created Timestamp
type: integer
description: >-
The Unix timestamp (in seconds) of when the chat
completion chunk was created.
object:
allOf:
- title: Object Type
type: string
default: chat.completion.chunk
description: >-
The type of object, which is always
`chat.completion.chunk`.
choices:
allOf:
- title: Choices
type: array
items:
$ref: '#/components/schemas/ChatCompletionsChunkChoice'
description: >-
A list of chat completion choices. Can be more than one if
`n` is greater than 1.
title: ChatCompletionsResponseEventStream
refIdentifier: '#/components/schemas/ChatCompletionsResponseEventStream'
requiredProperties:
- id
- model
- created
- object
- choices
examples:
example:
value:
id: <string>
model: <string>
created: 123
object: chat.completion.chunk
choices:
- index: 123
finish_reason: stop
delta:
content: <string>
role: system
description: OK
deprecated: false
type: path
components:
schemas:
ChatCompletionsMessage:
title: Message
type: object
required:
- content
- role
properties:
content:
title: Message Content
oneOf:
- type: string
description: The text contents of the message.
- type: array
items:
$ref: '#/components/schemas/ChatCompletionsMessageContentChunk'
description: An array of content parts for multimodal messages.
description: >-
The contents of the message in this turn of conversation. Can be a
string or an array of content parts.
role:
title: Role
type: string
enum:
- system
- user
- assistant
description: The role of the speaker in this conversation.
ChatCompletionsMessageContentChunk:
title: ChatCompletionsMessageContentChunk
type: object
properties:
type:
title: Content Part Type
type: string
enum:
- text
- image_url
description: The type of the content part.
text:
title: Text Content
type: string
description: The text content of the part.
image_url:
title: Image URL Content
type: object
properties:
url:
title: Image URL
type: string
format: uri
description: URL for the image (base64 encoded data URI or HTTPS).
required:
- url
description: An object containing the URL of the image.
required:
- type
description: Represents a part of a multimodal message content.
UsageInfo:
title: UsageInfo
type: object
properties:
prompt_tokens:
title: Prompt Tokens
type: integer
completion_tokens:
title: Completion Tokens
type: integer
total_tokens:
title: Total Tokens
type: integer
search_context_size:
title: Search Context Size
type: string
nullable: true
citation_tokens:
title: Citation Tokens
type: integer
nullable: true
num_search_queries:
title: Number of Search Queries
type: integer
nullable: true
reasoning_tokens:
title: Reasoning Tokens
type: integer
nullable: true
required:
- prompt_tokens
- completion_tokens
- total_tokens
ChatCompletionsChoice:
title: ChatCompletionsChoice
type: object
properties:
index:
title: Index
type: integer
finish_reason:
title: Finish Reason
type: string
enum:
- stop
- length
nullable: true
message:
$ref: '#/components/schemas/ChatCompletionsMessage'
required:
- index
- message
ChatCompletionsChunkChoice:
title: ChatCompletionsChunkChoice
type: object
properties:
index:
title: Index
type: integer
finish_reason:
title: Finish Reason
type: string
enum:
- stop
- length
nullable: true
delta:
$ref: '#/components/schemas/ChatCompletionsMessage'
required:
- index
- delta
ApiPublicSearchResult:
title: ApiPublicSearchResult
type: object
properties:
title:
title: Title
type: string
url:
title: URL
type: string
format: uri
date:
title: Date
type: string
format: date
nullable: true
required:
- title
- url
````