REST API
Reference
The REST API provides a convenient way to manage both collections and documents inside collections from external tools. This can be used in other applications to add, update and delete content that is indexed in the LLM application whenever content is added, changed or deleted the application.
Collections Resource
GET /wikis/{wikiName}/aiLLM/collections
Returns a list of all collection IDs that the current user can access as an array of strings.
Collection Resource
A collection object has the following properties:
| Name | Type | Description |
|---|---|---|
| id | String | id of the collection |
| title | String | pretty name of the collection |
| embedding_model | String | the embedding model as reference of the page that defines the model |
| chunking_method | String | the chunking method, should be maxChars |
| chunking_max_size | int | the maximum size of a chunk |
| chunking_overlap_offset | int | the overlap of chunks |
| document_spaces | List of strings | the list of XWiki spaces indexed by this collection, currently not used |
| allow_guests | boolean | if guests can query this collection (as part of a chat completion) |
| query_groups | List of strings | the list of groups that are allowed to query this collection (as part of a chat completion). This is only used when guests aren't allowed to query the collection. |
| rights_check_method | String | the method used for checking access rights of individual documents during queries. Supported values: public, external. See also the Authorization section of the Index for the LLM Application. |
| rights_check_method_configuration | Object | options of the rights check method, values depend on the selected rights check method. The "external" rights check method supports the url parameter which is the URL that is used to check rights for all found documents. |
GET /wikis/{wikiName}/aiLLM/collections/{collectionName}
Returns the collection of the given name.
PUT /wikis/{wikiName}/aiLLM/collections/{collectionName}
Creates or updates the collection of the given name. The body of the request is a collection, if not all properties are specified, only the specified properties are updated.
DELETE /wikis/{wikiName}/aiLLM/collections/{collectionName}
Deletes the collection of the given name
GET /wikis/{wikiName}/aiLLM/collections/{collectionName}/documents
Returns a list of document IDs that are contained in the collection of the given name. This resource supports the following query parameters:
| Name | Description |
|---|---|
| start | the index of the first document to retrieve (default: 0) |
| number | the number of documents to retrieve (default: -1) |
Document Resource
A document object has the following properties, all properties are strings:
| Name | Description |
|---|---|
| id | id of the document |
| title | pretty name of the document |
| language | the language of the document (currently not used) |
| url | the URL of the document, used to display a link to the original resource when the document is used as context in a chat |
| collection | the name of the collection the document is part of |
| mimetype | the mime type of the document, currently not used, could be used in the future to use a chunking method that is specific to the mime type |
| content | the content of the document that is indexed |
GET /wikis/{wikiName}/aiLLM/collections/{collectionName}/documents/{documentID}
Returns the document of the given name in the collection of the given name.
PUT /wikis/{wikiName}/aiLLM/collections/{collectionName}/documents/{documentID}
Creates or updates the document of the given name in the collection of the given name. The body of the request is a document, if not all properties are specified, only the specified properties are updated.
DELETE /wikis/{wikiName}/aiLLM/collections/{collectionName}/documents/{documentID}
Deletes the document of the given name in the collection of the given name.
LLM 0.8+
Search Resource
The search resource allows searching in indexed content. In contrast to the previous APIs, rights aren't checked based on standard XWiki rights but based on the allow_guests flag and the query groups. This API is basically the same as the search_wiki tool in the MCP Server.
POST /wikis/{wikiName}/aiLLM/search
Supported parameters:
| Name | Type | Description |
|---|---|---|
| query | String | The query to search for |
| collection | String (can be specified several times) | The IDs of the collections to search in, when omitted, all accessible collections are searched |
| limitKeywordResults | int | The maximum number of results to return based on keyword search (default: 10) |
| limitSemanticResults | int | The maximum number of results to return based on semantic search (default: 10) |
Search Collections Resource
The search collections resource returns all collections that the current user can access for search. This allows presenting users a list of collections they can select for search.
GET /wikis/{wikiName}/aiLLM/search/collections
Supported parameters: none.
Result: A list of collection resources with only id and title properties.