Local API Guide contents
Overview
Lists the collections you made on the app's Knowledge page, with their ids. Use a collection's name or id with knowledge on chat completions or collection in Knowledge search.
Request
| Parameter | Description |
|---|---|
| Authorization header | Authorization: Bearer <key>, only when Require API key is on in the app. |
Response
| Field | Description |
|---|---|
objectstring | list |
search_readyboolean | Whether knowledge search can run now (the knowledge model is installed and a model is loaded). |
data[].idstring | The collection id, like c:3. |
data[].namestring | The name shown in the app. |
data[].documentsinteger | Documents in the collection. |
Example
curl http://localhost:1234/v1/knowledge/collectionsimport requests for c in requests.get("http://localhost:1234/v1/knowledge/collections").json()["data"]: print(c["id"], c["name"], c["documents"])
const { data } = await (await fetch("http://localhost:1234/v1/knowledge/collections")).json(); console.table(data);
{
"object": "list",
"search_ready": true,
"data": [
{ "id": "c:1", "name": "My documents", "documents": 12 },
{ "id": "c:3", "name": "Policies", "documents": 4 }
]
}Errors
| Status | Code | When |
|---|---|---|
| 401 | invalid_api_key | Require API key is on and the key is missing or wrong. |
| 503 | knowledge_unavailable | The knowledge database could not be opened. |