# 402 API Error (Hitting Credit Limits)

**URL:** <https://forum.codecrafters.io/t/402-api-error-hitting-credit-limits/16366>\
**Category:** Bug Reports\
**Tags:** challenge:claude-code\
**Created:** [November 9, 2026, 4:21am UTC](https://forum.codecrafters.io/t/402-api-error-hitting-credit-limits/16366 "2026-11-09T04:21:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TinySquid](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/tinysquid/32/29551_2.png) [@TinySquid](https://forum.codecrafters.io/u/TinySquid)\
**Post date:** [November 9, 2026, 4:21am UTC](https://forum.codecrafters.io/t/402-api-error-hitting-credit-limits/16366/1 "2026-11-09T04:21:44Z")

</div>

Each stage I progress to, I’ve had to drop `max_tokens`down further and further until I got it to 100 tokens, and I still hit the 402 error about credit limits and can no longer continue the challenge:

```auto
[your_program] OpenAI API Error: 402 This request's maximum cost exceeds your available credits. Add credits, or lower max_tokens or prompt size.

```

```auto
[your_program] OpenAI API Error: 402 This request would exceed your available credits given your
 current in-flight requests. Retry after in-flight requests settle, or add credits.

```

```auto
[your_program] OpenAI API Error: 402 This request requires more credits, or fewer max_tokens. You requested up to 256 tokens, but can only afford 57. To increase, visit https://openrouter.ai/settings/credits and add more credits

```

Don’t think 57 tokens for a request is enough to pass any tests…

Also, it seems like the test runner is self-destructing because it comes up with random flaky errors like:

```auto
[tester::#OQ5] Expected file README_old.md to not exist, but it exists

[tester::#OQ5] Test failed

```

Works fine locally using a free OpenRouter model.  
Question: why hardcode it to Haiku 4.5? Allowing free models on the remote end would save y’all a few pennies at least.

---

<div class="post-metadata">

**Author:** ![baruisoham](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/baruisoham/32/13601_2.png) [@baruisoham](https://forum.codecrafters.io/u/baruisoham)\
**Post date:** [November 9, 2026, 7:59am UTC](https://forum.codecrafters.io/t/402-api-error-hitting-credit-limits/16366/3 "2026-11-09T07:59:03Z")

</div>

Facing the same issue. They should hardcode to one of the cheaper models instead.
