The Request API allows you to build a request, where you can specify filtering criteria to retrieve all requests made by a user.

Use Cases

  • Monitor your user’s usage pattern and behavior.
  • Access user-specific requests to pinpoint the errors and bebug more efficiently.
  • Track requests and costs per user to facilitate better cost control.
  • Detect unusual or potentially harmful user behaviors.

Retrieving Requests by User ID

Here’s an example to get all the requests where user_id is abc@email.com.

curl --request POST \
  --url https://api.helicone.ai/v1/request/query \
  --header 'Content-Type: application/json' \
  --header 'authorization: Bearer sk-<your-helicone-api-key>' \
  --data '{
  "filter": {
    "request": {
      "user_id": {
        "equals": "abc@email.com"
      }
    }
  }
}'

By using the Request API, the code snippet will dynamically populate on the page, so you can copy and paste.

Adding Additional Filters

You can structure your query to add any number of filters.

Note: To add multiple filters, change the filter to a branch and nest the ANDs/ORs as an abstract syntax tree.

curl --request POST \
  --url https://api.helicone.ai/v1/request/query \
  --header 'Content-Type: application/json' \
  --header 'authorization: Bearer sk-<your-helicone-api-key>' \
  --data '{
  "filter": {
    "operator": "and",
    "right": {
      "request": {
        "model": {
          "contains": "gpt-4"
        }
      }
    },
    "left": {
      "request": {
        "user_id": {
          "equals": "abc@email.com"
        }
      }
    }
  }
}'