[GH-ISSUE #10688] citations via endpoint API #54660

Closed
opened 2026-05-05 16:32:29 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @Ashbajawed on GitHub (Feb 24, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/10688

how can we get citations via end point API using python

def chat_with_collection(token, model, query, collection_id):
url = f'{main_url}/api/chat/completions'
headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
}
payload = {
'model': model,

"messages": [
    { "role": "user", "content": prompt,
   "sources": True,
     },
    {"role": "user", "content": query,"sources": True,
    },
],
'files': [{'type': 'file', 'id': collection_id}],
'params': {'top_k': 30, 'top_p': 0.9, 'min_p': 0, 'repeat_last_n': 64},

}

response = requests.post(
url = f'{main_url}/api/chat/completions',
headers=headers, data=json.dumps(payload), verify=False, stream=True,
)
return response

Originally created by @Ashbajawed on GitHub (Feb 24, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/10688 how can we get citations via end point API using python def chat_with_collection(token, model, query, collection_id): url = f'{main_url}/api/chat/completions' headers = { 'Authorization': f'Bearer {token}', 'Content-Type': 'application/json' } payload = { 'model': model, "messages": [ { "role": "user", "content": prompt, "sources": True, }, {"role": "user", "content": query,"sources": True, }, ], 'files': [{'type': 'file', 'id': collection_id}], 'params': {'top_k': 30, 'top_p': 0.9, 'min_p': 0, 'repeat_last_n': 64}, } response = requests.post( url = f'{main_url}/api/chat/completions', headers=headers, data=json.dumps(payload), verify=False, stream=True, ) return response
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#54660