List files and check their status
https://gptunnel.ru/v1/database/file/listList 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
| Parameter | Type | Description |
|---|---|---|
Authorization* | string | API key |
Request parameters
| Parameter | Type | Description |
|---|---|---|
databaseId* | string | ID Knowledge base |
fileId | string | File ID |
Example request
Section titled “Example request”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 jsonimport osfrom urllib.parse import urlencodefrom 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))curl --fail-with-body \ --get 'https://gptunnel.ru/v1/database/file/list' \ --header "Authorization: ${GPTUNNEL_API_KEY:?Set GPTUNNEL_API_KEY}" \ --data-urlencode "databaseId=${GPTUNNEL_DATABASE_ID:?Set GPTUNNEL_DATABASE_ID}" \ --data-urlencode "fileId=${GPTUNNEL_FILE_ID:?Set GPTUNNEL_FILE_ID}"const key = process.env.GPTUNNEL_API_KEYif (!key) throw new Error('Set GPTUNNEL_API_KEY')const databaseId = process.env.GPTUNNEL_DATABASE_IDif (!databaseId) throw new Error('Set GPTUNNEL_DATABASE_ID')const fileId = process.env.GPTUNNEL_FILE_IDif (!fileId) throw new Error('Set GPTUNNEL_FILE_ID')
const url = new URL('https://gptunnel.ru/v1/database/file/list')url.searchParams.set('databaseId', databaseId)url.searchParams.set('fileId', fileId)const response = await fetch(url, { headers: { Authorization: key } })if (!response.ok) throw new Error(await response.text())console.log(await response.json())Example response
Section titled “Example 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 }]{ "error": { "message": "Unauthorized", "type": "unauthorized_request_error", "param": null, "code": null }}