Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

docs(perplexity.md): show how to get 'return_citations'

Krrish Dholakia8cbf8d567152
diff --git a/docs/my-website/docs/providers/perplexity.md b/docs/my-website/docs/providers/perplexity.md
index 7cfc4c8619f..446f22b1f2f 100644
--- a/docs/my-website/docs/providers/perplexity.md
+++ b/docs/my-website/docs/providers/perplexity.md
@@ -1,3 +1,6 @@
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
# Perplexity AI (pplx-api)
https://www.perplexity.ai
@@ -38,7 +41,7 @@ for chunk in response:
## Supported Models
-All models listed here https://docs.perplexity.ai/docs/model-cards are supported
+All models listed here https://docs.perplexity.ai/docs/model-cards are supported. Just do `model=perplexity/<model-name>`.
| Model Name | Function Call |
|--------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
@@ -60,3 +63,72 @@ All models listed here https://docs.perplexity.ai/docs/model-cards are supported
+
+## Return citations
+
+Perplexity supports returning citations via `return_citations=True`. [Perplexity Docs](https://docs.perplexity.ai/reference/post_chat_completions). Note: Perplexity has this feature in **closed beta**, so you need them to grant you access to get citations from their API.
+
+If perplexity returns citations, LiteLLM will pass it straight through.
+
+:::info
+
+For passing more provider-specific, [go here](../completion/provider_specific_params.md)
+:::
+
+<Tabs>
+<TabItem value="sdk" label="SDK">
+
+```python
+from litellm import completion
+import os
+
+os.environ['PERPLEXITYAI_API_KEY'] = ""
+response = completion(
+ model="perplexity/mistral-7b-instruct",
+ messages=messages,
+ return_citations=True
+)
+print(response)
+```
+
+</TabItem>
+<TabItem value="proxy" label="PROXY">
+
+1. Add perplexity to config.yaml
+
+```yaml
+model_list:
+ - model_name: "perplexity-model"
+ litellm_params:
+ model: "llama-3.1-sonar-small-128k-online"
+ api_key: os.environ/PERPLEXITY_API_KEY
+```
+
+2. Start proxy
+
+```bash
+litellm --config /path/to/config.yaml
+```
+
+3. Test it!
+
+```bash
+curl -L -X POST 'http://0.0.0.0:4000/chat/completions' \
+-H 'Content-Type: application/json' \
+-H 'Authorization: Bearer sk-1234' \
+-d '{
+ "model": "perplexity-model",
+ "messages": [
+ {
+ "role": "user",
+ "content": "Who won the world cup in 2022?"
+ }
+ ],
+ "return_citations": true
+}'
+```
+
+[**Call w/ OpenAI SDK, Langchain, Instructor, etc.**](../proxy/user_keys.md#chatcompletions)
+
+</TabItem>
+</Tabs>