DEPRECATION NOTICE
This version of our API has been deprecated and is longer supported. Please use our v4 API docs, which you can navigate to using the sidebar on the left.
Submit File for Indexing
You must first submit a file to this endpoint so that it can be indexed. Usually, indexing takes a few seconds, but can take longer depending on the size of your file. Currently, we only support files with the following extensions: '.txt', '.json', '.html', '.pdf', and '.zip' (if the zip file only contains the previous 4 files and no nested zips). You must use reference this file using a URL that is accessible over HTTP.
Authentication
- Name
x-api-key
- Type
- string
- Description
Your Meru API Key
Required Attributes
- Name
files
- Type
- string or array
- Description
URL of file accessible over HTTP. File type must be one of the following: JSON, HTML, TXT, PDF, or ZIP.
Optional Attributes
- Name
index_name
- Type
- string
- Description
Name for you to refer to index with.
Response Attributes
- Name
err_code
- Type
- string
- Description
err_code : 0 means success. If err_code != 0, please refer to err_msg attribute for details.
- Name
id
- Type
- string
- Description
Reference identifier of the index for use while querying.
- Name
status_code
- Type
- string
- Description
status_code : 1 means the indexing is still in progress. To monitor the request for completion, see the associated GET function.
- Name
index_name
- Type
- string
- Description
Index name you provided during creation of index. If none provided, empty string ("").
Request
curl https://api.usemeru.com/refine/v3/files \
-H 'Content-Type: application/json' \
-H "x-api-key: ${api_key}" \
-d '{
"files" : ${FILE_URL},
"index_name": ${INDEX_NAME}
}'
Response
{
"err_code": 0,
"id": INDEX_ID,
"status_code": 1
}
Monitor Indexing
Monitor the progress of the indexing operation.
Authentication
- Name
x-api-key
- Type
- string
- Description
Your Meru API Key
Response Attributes
- Name
err_code
- Type
- string
- Description
err_code : 0 means success. If err_code != 0, please refer to err_msg attribute for details.
- Name
id
- Type
- string
- Description
Reference identifier of the index for use while querying.
- Name
status_code
- Type
- string
- Description
status_code : 1 means the indexing is still in progress. status_code : 0 means the indexing is complete and the document can now be queried. status_code: 2 means that the request timed out.
Request
curl https://api.usemeru.com/refine/v3/files/INDEX_ID \
-H 'Content-Type: application/json' \
-H "x-api-key: ${api_key}"
Response
{
"err_code": 0,
"id": INDEX_ID,
"status_code": 1,
"index_name": ""
}
Delete Index
Authentication
- Name
x-api-key
- Type
- string
- Description
Your Meru API Key
Response Attributes
- Name
err_code
- Type
- string
- Description
err_code : 0 means success. If err_code != 0, please refer to err_msg attribute for details.
- Name
id
- Type
- string
- Description
Reference identifier of the index deleted.
Request
curl -X DELETE https://api.usemeru.com/refine/v3/files/INDEX_ID \
-H 'Content-Type: application/json' \
-H "x-api-key: ${api_key}"
Response
{
"err_code": 0,
"id": INDEX_ID
}
Run Query on Indexed File
Once you have file indexed, you can run queries on that file using a prompt. You can reference the file using the INDEX_ID returned by the prior function.
Authentication
- Name
x-api-key
- Type
- string
- Description
Your Meru API Key
Required Attributes
- Name
file_id
- Type
- string
- Description
ID of index associated with the file (returned by the function above)
- Name
prompt
- Type
- string
- Description
Query string. Example "What is the author's email address?"
Optional Attributes
- Name
temperature
- Type
- Number
- Description
Temperature used for LLM predictor: Min 0, Max 2
- Name
max_tokens
- Type
- Integer
- Description
Temperature used for LLM predictor: Min 256, Max 2048
Request
curl https://api.usemeru.com/refine/v3/predict \
-H 'Content-Type: application/json' \
-H "x-api-key: ${api_key}" \
-d '{
"model_id": "context-text-davinci-003",
"inputs": {
"file_id": ${INDEX_ID},
"prompt": ${PROMPT},
"temperature": 0.5,
"max_tokens": 256
}
}'
Response
{
"err_code": 0,
"id": PREDICT_ID,
"outputs": {
"object": "text_completion",
"choices": [
{
"text": "\nThe author's email address is not provided in the context information."
}
],
"source": "> Source (Doc id: doc.txt): email: blank",
},
"status_code": 0
}
Monitor Predictions for Long (Async) Queries
Once you have queried an index, if the request times out on the API gateway, you can poll the predict endpoint using the PREDICT_ID returned by the predict function.
Authentication
- Name
x-api-key
- Type
- string
- Description
Your Meru API Key
Request
curl https://api.usemeru.com/refine/v3/predict/PREDICT_ID \
-H 'Content-Type: application/json' \
-H "x-api-key: ${api_key}"
Response
{
"err_code": 0,
"id": PREDICT_ID,
"outputs": {
"object": "text_completion",
"choices": [
{
"text": "\nThe author's email address is not provided in the context information."
}
],
"source": "> Source (Doc id: doc.txt): email: blank",
},
"status_code": 0
}
Delete Prediction
Authentication
- Name
x-api-key
- Type
- string
- Description
Your Meru API Key
Response Attributes
- Name
err_code
- Type
- string
- Description
err_code : 0 means success. If err_code != 0, please refer to err_msg attribute for details.
- Name
id
- Type
- string
- Description
Reference identifier of the query deleted.
Request
curl -X DELETE https://api.usemeru.com/refine/v3/predict/PREDICT_ID \
-H 'Content-Type: application/json' \
-H "x-api-key: ${api_key}"
Response
{
"err_code": 0,
"id": PREDICT_ID
}