Latest Version: v4

Introducing the newest dense data retrieval API. With better OCR that can handle all your documents at breakneck speed.

POSThttps://api.usemeru.com/refine/v4/files

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

POST
refine/v4/files
curl https://api.usemeru.com/refine/v4/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
}

GEThttps://api.usemeru.com/refine/v4/files/INDEX_ID

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

GET
refine/v4/files/INDEX_ID
curl https://api.usemeru.com/refine/v4/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": ""
}

GEThttps://api.usemeru.com/refine/v4/files

List Indices

List all your indices.

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
    indices
    Type
    list
    Description

    List containing your indices

Request

GET
refine/v4/files
curl https://api.usemeru.com/refine/v4/files \
  -H 'Content-Type: application/json' \
  -H "x-api-key: ${api_key}"

Response

{
  "err_code": 0,
  "indices": [
    {
      "creation_source": "",
      "creation_time": "",
      "status_code": "",
      "index_name": "",
      "files": [],
      "id": ""
    }
  ]
}

DELETEhttps://api.usemeru.com/refine/v4/files/INDEX_ID

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

DELETE
refine/v4/files/INDEX_ID
curl -X DELETE https://api.usemeru.com/refine/v4/files/INDEX_ID \
  -H 'Content-Type: application/json' \
  -H "x-api-key: ${api_key}"

Response

{
  "err_code": 0,
  "id": INDEX_ID
}

POSThttps://api.usemeru.com/refine/v4/predict

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

POST
refine/v4/predict
curl https://api.usemeru.com/refine/v4/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
}   

GEThttps://api.usemeru.com/refine/v4/predict/PREDICT_ID

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

GET
refine/v4/predict/PREDICT_ID
curl https://api.usemeru.com/refine/v4/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
}    

DELETEhttps://api.usemeru.com/refine/v4/predict/PREDICT_ID

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

DELETE
refine/v4/predict/PREDICT_ID
curl -X DELETE https://api.usemeru.com/refine/v4/predict/PREDICT_ID \
  -H 'Content-Type: application/json' \
  -H "x-api-key: ${api_key}"

Response

{
  "err_code": 0,
  "id": PREDICT_ID
}