Skip to content

List files and check their status

GEThttps://gptunnel.ru/v1/database/file/list

List all files. Pass databaseId to retrieve the files in one knowledge base.

Check one file. Also pass fileId to retrieve an array with one entry. If the file is not found, the API returns HTTP 404.

After you add a file, use its id to poll for updates. When status is ready, processing is complete. Check progress while the file is processing and error if processing fails.

Request headers

ParameterTypeDescription
Authorization*stringAPI key

Request parameters

ParameterTypeDescription
databaseId*stringID Knowledge base
fileIdstringFile ID

Set GPTUNNEL_API_KEY to your API key. Set GPTUNNEL_DATABASE_ID to the ID from the list of knowledge bases and GPTUNNEL_FILE_ID to the file’s id from the add file response. This example retrieves one file. To list every file in the knowledge base, send only databaseId.

import json
import os
from urllib.parse import urlencode
from urllib.request import Request, urlopen
fields = {
'databaseId': os.environ['GPTUNNEL_DATABASE_ID'],
'fileId': os.environ['GPTUNNEL_FILE_ID'],
}
request = Request(
'https://gptunnel.ru/v1/database/file/list' + '?' + urlencode(fields),
headers={'Authorization': os.environ['GPTUNNEL_API_KEY']},
)
with urlopen(request, timeout=30) as response:
print(json.load(response))

Example of a separate file processed with the divider | The values may differ from the file added on the previous page.

[
{
"id": "66a346f64dcb57627c03d596",
"createDate": "2024-07-26T06:49:27.430Z",
"status": "ready",
"name": "Split check",
"databaseId": "669b1824c0d8dbde07d07d10",
"chunkSize": 1024,
"overlapSize": 0,
"splitVariable": "|",
"tokenCount": 6,
"tokenCost": "0.0003",
"error": null,
"progress": 100,
"chunkCount": 3
}
]