Helicone Community Page

Updated 6 months ago

Gateway timeout

Heya, any tips on how to address a Gateway timeout error when querying for requests?
Plain Text
<head><title>504 Gateway Time-out</title></head>
<body>
<center><h1>504 Gateway Time-out</h1></center>
</body>
</html>


Here's roughly what I'm doing:

Plain Text
HELICONE_URL = "https://api.helicone.ai/v1/request/query"
HELICONE_API_KEY = os.getenv("HELICONE_API_KEY")
HELICONE_HEADERS = {
    "Content-Type": "application/json",
    "authorization": f"Bearer {HELICONE_API_KEY}",
}


def get_helicone_requests(
    project: str, created_time_start: str, created_time_end: str, limit_n: int
):
    """
    Get Helicone requests for a particular project.
    """
    print(
        f"getting helicone requests for {project}, created time start {created_time_start}, created time end {created_time_end}..."
    )

    payload = {
        "filter": {
            "request": {
                "user_id": {"equals": project},
                "created_at": {
                    "gte": created_time_start,
                    "lte": created_time_end,
                },
            }
        },
        "limit": limit_n,
        "sort": {"created_at": "asc"},
    }
    try:
        response = requests.post(
            HELICONE_URL, headers=HELICONE_HEADERS, data=json.dumps(payload)
        )
        if response.status_code != 200:
            raise RuntimeError(f"Error occurred, response: {response.text}")
        return response.json().get("data", [])
    except Exception as e:
        print(f"error occured: {e}")
        print(traceback.format_exc())
        return []


Seems to happen sporadically but go through otherwise
J
w
8 comments
Hi Wookie - can you share a bit more? What is your time variables and the limit being set to?
limit 20, time the last hour
I fixed this by not using multiple filtering and instead using the anded single filters πŸ™‚
Hmm should be fast without a timeout
yup. Multiple filtering would be cool to have in the future! πŸ™‚
Ohhh right - multiple filtering is a bit wonky, definitely want to use those ands
Thanks for working through this and fonding a solution
Thanks for taking a look!
Add a reply
Sign up and join the conversation on Discord