# Pinging the API?

**URL:** <https://discuss.ai.google.dev/t/pinging-the-api/34704>\
**Category:** Gemini API\
**Tags:** gemini-15, api\
**Created:** [July 29, 2024, 4:13am UTC](https://discuss.ai.google.dev/t/pinging-the-api/34704 "2024-07-29T04:13:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Macha](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/macha/32/179_2.png) [@Macha](https://discuss.ai.google.dev/u/Macha)\
**Post date:** [July 29, 2024, 4:13am UTC](https://discuss.ai.google.dev/t/pinging-the-api/34704/1 "2024-07-29T04:13:20Z")

</div>

This might be one of those questions that’s so simple to answer it’s blown completely over my head, but alas I’m drawing a blank.

How exactly can I ping any of the API endpoints (via REST) to ensure they return a status code `200` before I do stuff?

There have been several instances now where I’ve received an error code `500` (internal server error), which mucks with my game logic. It would be nice to check for this code _before_ I run anything to it. That way, I can lock features until the ping returns `200`s again.

I’m also assuming I don’t get charged per ping, right? And that I can send a reasonable amount of pings without actually causing issues? Ideally, I’d like to call it once per frame in my game, hence why I’m asking.

---

<div class="post-metadata">

**Author:** ![Curt\_Kennedy](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/curt_kennedy/32/168_2.png) [@Curt\_Kennedy](https://discuss.ai.google.dev/u/Curt_Kennedy)\
**Post date:** [July 29, 2024, 6:29am UTC](https://discuss.ai.google.dev/t/pinging-the-api/34704/2 "2024-07-29T06:29:52Z")

</div>

You could try sending a very small prompt over. Like “Hi” or something.

---

<div class="post-metadata">

**Author:** ![OrangiaNebula](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/orangianebula/32/480_2.png) [@OrangiaNebula](https://discuss.ai.google.dev/u/OrangiaNebula)\
**Post date:** [July 29, 2024, 6:32am UTC](https://discuss.ai.google.dev/t/pinging-the-api/34704/3 "2024-07-29T06:32:02Z")

</div>

A practical approach is: when you get a 500, resubmit the exact same request that caused it. Treat it similar to the 429, you can retry the call. Chances are, your request will be randomly routed to a different, healthy server that can service your request.

Put a cap on the number of automatic retries, of course.

And you don’t get charged for things that didn’t work, the 400’s or 403’s or 500’s. They don’t get billed.

Hope that helps!

---

<div class="post-metadata">

**Author:** ![Macha](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/macha/32/179_2.png) [@Macha](https://discuss.ai.google.dev/u/Macha)\
**Post date:** [July 29, 2024, 6:41am UTC](https://discuss.ai.google.dev/t/pinging-the-api/34704/4 "2024-07-29T06:41:14Z")

</div>

Ah, that might actually work. It feels like more of a bandaid, but for now, it should do the trick.

> [@Curt\_Kennedy](#):
>
> You could try sending a very small prompt over. Like “Hi” or something.

Lol, I love you boo, but imagine running that @ 1000 FPS 😆. Or even just 100 FPS. Even if I scaled my game to force it into 60 FPS, that’s a lot. Now imagine this per player. It won’t scale well.

In a perfect world, it would still be nice to have a constant run-time check, but retrying the call will do for now. Thanks!

---

<div class="post-metadata">

**Author:** ![afirstenberg](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/afirstenberg/32/202_2.png) [@afirstenberg](https://discuss.ai.google.dev/u/afirstenberg)\
**Post date:** [July 29, 2024, 9:41am UTC](https://discuss.ai.google.dev/t/pinging-the-api/34704/5 "2024-07-29T09:41:44Z")

</div>

> [@Macha](#):
>
> Ideally, I’d like to call it once per frame in my game

> [@Macha](#):
>
> imagine running that @ 1000 FPS

A ping at those rates is pretty unreasonable, and wouldn’t improve your gameplay a whole lot. If you assume a ping response time of 10ms (which is generous for a UDP ping - and the API is TCP), you’re down to 100 FPS. You absolutely don’t want to limit your game play to an external feature check.

@OrangiaNebula has the right answer - attempt a request and use exponential backoff if you get an error situation. And don’t tie this to the main game activity thread.

---

<div class="post-metadata">

**Author:** ![Curt\_Kennedy](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/curt_kennedy/32/168_2.png) [@Curt\_Kennedy](https://discuss.ai.google.dev/u/Curt_Kennedy)\
**Post date:** [July 29, 2024, 2:57pm UTC](https://discuss.ai.google.dev/t/pinging-the-api/34704/6 "2024-07-29T14:57:59Z")

</div>

> [@Macha](#):
>
> In a perfect world, it would still be nice to have a constant run-time check, but retrying the call will do for now. Thanks!

For general uptime checks, you can run the “Hi” prompt every minute or so. For tokens per minute output rate measurements, you would run other prompts that generate tokens, and a good performance metric is output tokens per minute … this approximation is better with smaller input prompts that generate a lot of output tokens.

But for errors, you will have to retry, exponential backoff as said above, and then wait, or you will have to accept this and “drop a frame”, or whatever, like actual video games.

But I think the delay from making the call through an API and coming back is multiple seconds at least. And so your are hundreds or thousands of frames behind. This is true for even local inferences.

You would have to build a small effecient local model to get the kind of frame rates you want. I know NVIDIA had a demo of some such a little while back, but that’s local stuff we’re talking.

As for making the API call with “Hi”, this is the only way to check that there isn’t an internal model error, or some other internal issue. Most of the time, the API endpoint/network layer is just fine. It’s the internal code/network that crashes. I know tangentially because I see these when I built my own internal API endpoints … it always points to some “internal server error”, which for me, is a bug in the code. 🤣

But if you still want to see if the general enpoint is alive, without getting into the internals, you can try something like an empty GET request. But not all API’s are REST, or have a GET method associated with them.

---

<div class="post-metadata">

**Author:** ![system](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/system/32/1_2.png) [@system](https://discuss.ai.google.dev/u/system)\
**Post date:** [November 5, 2026, 6:17pm UTC](https://discuss.ai.google.dev/t/pinging-the-api/34704/7 "2026-11-05T18:17:12Z")

</div>

Closed on November 5, 2026, 6:17pm UTC

This thread was automatically closed 60 days after the last reply. If you are running into an issue, please create a new post.
