File tree Expand file tree Collapse file tree 1 file changed +40
-1
lines changed Expand file tree Collapse file tree 1 file changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,46 @@ The full API of this library can be found in [api.md](api.md).
2020pip install perplexityai
2121```
2222
23- ## Usage
23+ ## Search API
24+
25+ Get web search results:
26+
27+ ``` python
28+ import os
29+ from perplexity import Perplexity
30+
31+ client = Perplexity(
32+ api_key = os.environ.get(" PERPLEXITY_API_KEY" ), # This is the default and can be omitted
33+ )
34+
35+ search = client.search.create(
36+ query = " latest AI developments 2024" ,
37+ max_results = 5
38+ )
39+
40+ for result in search.results:
41+ print (f " { result.title} : { result.url} " )
42+ ```
43+
44+ ## Content API
45+
46+ Extract and process content from URLs:
47+
48+ ``` python
49+ from perplexity import Perplexity
50+
51+ client = Perplexity()
52+
53+ content = client.content.create(
54+ urls = [" https://en.wikipedia.org/wiki/Perplexity_AI" ]
55+ )
56+
57+ for result in content.results:
58+ print (f " Title: { result.title} " )
59+ print (f " Content: { result.content[:200 ]} ... " )
60+ ```
61+
62+ ## Chat Completions
2463
2564The full API of this library can be found in [ api.md] ( api.md ) .
2665
You can’t perform that action at this time.
0 commit comments