Skip to content

Perplexity AI Citations #996

@vikigenius

Description

@vikigenius

Description

Perplexity AI has a citations field in their response that usually works like this

response_stream = client.chat.completions.create(
    model="sonar-pro",
    messages=messages,
    stream=True,
)

citations = []
for response in response_stream:
    print(response.choices[0].delta.content, end="")
    citations.extend(response.citations)

You now have access to a list of citations that you can use reliably.

Is there any way in pydantic_ai to access this?

The perplexity model is not very reliable at producing inline citations. So it would be useful to be able to do this and access their citations.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions