I uploaded a knowledge base on the web side of open webui and I want to call it via python code, the api section of the manual on the official website gives the method to call it, but I really don't know what collection_id refers to? How do I get the collection_id?
Originally created by @zxjhellow2 on GitHub (Feb 24, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/10663
I uploaded a knowledge base on the web side of open webui and I want to call it via python code, the api section of the manual on the official website gives the method to call it, but I really don't know what collection_id refers to? How do I get the collection_id?

```import requests
def chat_with_collection(token, model, query, collection_id):
url = 'http://localhost:3000/api/chat/completions'
headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
}
payload = {
'model': model,
'messages': [{'role': 'user', 'content': query}],
'files': [{'type': 'collection', 'id': collection_id}]
}
response = requests.post(url, headers=headers, json=payload)
return response.json()
```
curl -H POST http://localhost:3000/api/v1/knowledge/ \
-H "Authorization: Bearer your api_key"
<!-- gh-comment-id:2677658558 -->
@zxjhellow2 commented on GitHub (Feb 24, 2025):
use this
```
curl -H POST http://localhost:3000/api/v1/knowledge/ \
-H "Authorization: Bearer your api_key"
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Originally created by @zxjhellow2 on GitHub (Feb 24, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/10663
I uploaded a knowledge base on the web side of open webui and I want to call it via python code, the api section of the manual on the official website gives the method to call it, but I really don't know what collection_id refers to? How do I get the collection_id?

@zxjhellow2 commented on GitHub (Feb 24, 2025):
use this