# ClaudeCode - Stage: Advertise the read tool: Runs locally, fails over server (API\_KEY error)

**URL:** https://forum.codecrafters.io/t/claudecode-stage-advertise-the-read-tool-runs-locally-fails-over-server-api-key-error/16189
**Category:** General
**Tags:** challenge:claude-code
**Created:** [June 30, 2026, 4:50pm UTC](https://forum.codecrafters.io/t/claudecode-stage-advertise-the-read-tool-runs-locally-fails-over-server-api-key-error/16189 "2026-06-30T16:50:23Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ronaldcumbal](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/ronaldcumbal/32/27103_2.png) [@ronaldcumbal](https://forum.codecrafters.io/u/ronaldcumbal)
#### Post date: [June 30, 2026, 4:50pm UTC](https://forum.codecrafters.io/t/claudecode-stage-advertise-the-read-tool-runs-locally-fails-over-server-api-key-error/16189/1 "2026-06-30T16:50:23Z")

</div>

Hi,

I can run this stage correctly in my local computer, but it fails the tests over the server. This is the error:

[your\_program] Traceback (most recent call last):  
[your\_program] File “”, line 203, in \_run\_module\_as\_main  
[your\_program] File “”, line 88, in \_run\_code  
[your\_program] File “/app/app/main.py”, line 54, in  
[your\_program] main()  
[your\_program] ~~~~ ^^  
[your\_program] File “/app/app/main.py”, line 17, in main  
[your\_program] raise RuntimeError(“OPENAI\_API\_KEY is not set”)  
[your\_program] RuntimeError: OPENAI\_API\_KEY is not set  
[tester::#AQ1] Expected program to exit with exit code 0, got 1 instead  
[tester::#AQ1] Test failed

I change the OpenRouter service to the OpenAI service directly, but I don’t see why that would be a problem.

Here is my code:

```auto
def main():
p = argparse.ArgumentParser()
p.add_argument("-p", required=True)
args = p.parse_args()

if not API_KEY:
    raise RuntimeError("OPENAI_API_KEY is not set")

client = OpenAI(api_key=API_KEY)#, base_url=BASE_URL)

```

Any help here?

---

<div class="post-metadata">

### Author: ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)
#### Post date: [June 30, 2026, 5:45pm UTC](https://forum.codecrafters.io/t/claudecode-stage-advertise-the-read-tool-runs-locally-fails-over-server-api-key-error/16189/3 "2026-06-30T17:45:11Z")

</div>

Hey @ronaldcumbal, the test runners don’t have an `OPENAI_API_KEY` environment variable set.

You can read the API key from `OPENROUTER_API_KEY` instead. That environment variable is available in the tester.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)
#### Post date: [July 5, 2026, 5:46pm UTC](https://forum.codecrafters.io/t/claudecode-stage-advertise-the-read-tool-runs-locally-fails-over-server-api-key-error/16189/4 "2026-07-05T17:46:09Z")

</div>

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
