Skip to content

Commit d2885d3

Browse files
committed
update README
1 parent 4dfbe4f commit d2885d3

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,46 @@ The full API of this library can be found in [api.md](api.md).
2020
pip 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

2564
The full API of this library can be found in [api.md](api.md).
2665

0 commit comments

Comments
 (0)