how to find collection_id? #4089

Closed
opened 2025-11-11 15:45:51 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @zxjhellow2 on GitHub (Feb 24, 2025).

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?
Image


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()
Originally created by @zxjhellow2 on GitHub (Feb 24, 2025). 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? ![Image](https://github.com/user-attachments/assets/7abc0cc1-b74a-4126-a792-03f6b087859a) ```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() ```
Author
Owner

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

use this

curl -H POST http://localhost:3000/api/v1/knowledge/ \
-H "Authorization: Bearer  your api_key"
@zxjhellow2 commented on GitHub (Feb 24, 2025): use this ``` curl -H POST http://localhost:3000/api/v1/knowledge/ \ -H "Authorization: Bearer your api_key" ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#4089