AI_APICallError: User not found with OpenRouter despite valid API key #1488

Closed
opened 2026-02-16 17:31:13 -05:00 by yindo · 13 comments
Owner

Originally created by @innersanctumtech on GitHub (Aug 25, 2025).

Originally assigned to: @thdxr on GitHub.

AI_APICallError: User not found with OpenRouter despite valid API key

OpenCode consistently fails with AI_APICallError: User not found when using OpenRouter models, despite having a valid API key that works perfectly with direct API calls.

Environment

•	OpenCode version: 0.5.24
•	Platform: macOS (Darwin 24.6.0)
•	OpenRouter API key: Valid (confirmed working)

Steps to Reproduce

1.	Set OPENROUTER_API_KEY environment variable with valid API key
2.	Verify OpenCode detects the key: opencode auth list shows “OpenRouter OPENROUTER_API_KEY”
3.	Try to use any OpenRouter model: opencode run -m "openrouter/google/gemini-2.5-flash" "test message"

Expected Behavior

OpenCode should successfully make API calls to OpenRouter models.

Actual Behavior

Error: AI_APICallError: User not found.

Evidence: Direct API Calls Work Perfectly

API Key Validation

curl -H "Authorization: Bearer $OPENROUTER_API_KEY" https://openrouter.ai/api/v1/auth/key

Result: Returns valid user data and rate limits

Direct Model Usage - Paid Model

curl -H "Authorization: Bearer $OPENROUTER_API_KEY" -H "Content-Type: application/json" -d '{"model":"google/gemini-2.5-flash","messages":[{"role":"user","content":"test"}],"max_tokens":10}' \
  https://openrouter.ai/api/v1/chat/completions

Result: Returns successful completion with generated text

Free Model Test

curl -H "Authorization: Bearer $OPENROUTER_API_KEY" -H "Content-Type: application/json" -d '{"model":"meta-llama/llama-3.3-70b-instruct:free","messages":[{"role":"user","content":"test"}],"max_tokens":10}' \
  https://openrouter.ai/api/v1/chat/completions

Result: Also works (when not rate-limited)

Invalid Key Test

curl -H "Authorization: Bearer invalid-key" -H "Content-Type: application/json" -d '{"model":"google/gemini-2.5-flash","messages":[{"role":"user","content":"test"}],"max_tokens":10}' \
  https://openrouter.ai/api/v1/chat/completions

Result: Returns authentication error (as expected)

OpenCode Debug Logs

OpenCode successfully finds and initializes the model:
INFO service=provider providerID=openrouter
modelID=google/gemini-2.5-flash found
INFO service=provider status=completed duration=47 providerID=openrouter getSDK

But then fails with:
ERROR service=session error={“error”:{“name”:“AI_APICallError”,…}}

Key Findings

1.	API key is valid — Direct OpenRouter API calls work perfectly
2.	OpenCode detects credentials — Shows in opencode auth list
3.	Model is found — OpenCode logs show successful model initialization
4.	Request fails in OpenCode — Same API key/model that works directly fails in OpenCode

Related Issues

•	#1631: AI_APICallError: No auth credentials found
•	#604: AI_APICallError: Not Found
•	#1002: No endpoints found that support tool use

Conclusion

This suggests OpenCode is not properly constructing API requests to OpenRouter, despite having valid credentials and successfully initializing the provider. The “User not found” error is misleading — the user/API key is valid, but something in OpenCode’s request formatting is causing OpenRouter to reject the authentication.

Originally created by @innersanctumtech on GitHub (Aug 25, 2025). Originally assigned to: @thdxr on GitHub. # AI_APICallError: User not found with OpenRouter despite valid API key OpenCode consistently fails with AI_APICallError: User not found when using OpenRouter models, despite having a valid API key that works perfectly with direct API calls. ## Environment • OpenCode version: 0.5.24 • Platform: macOS (Darwin 24.6.0) • OpenRouter API key: Valid (confirmed working) ## Steps to Reproduce 1. Set OPENROUTER_API_KEY environment variable with valid API key 2. Verify OpenCode detects the key: opencode auth list shows “OpenRouter OPENROUTER_API_KEY” 3. Try to use any OpenRouter model: opencode run -m "openrouter/google/gemini-2.5-flash" "test message" ## Expected Behavior OpenCode should successfully make API calls to OpenRouter models. ## Actual Behavior Error: AI_APICallError: User not found. ## Evidence: Direct API Calls Work Perfectly ### API Key Validation ```bash curl -H "Authorization: Bearer $OPENROUTER_API_KEY" https://openrouter.ai/api/v1/auth/key ``` Result: ✅ Returns valid user data and rate limits ### Direct Model Usage - Paid Model ```bash curl -H "Authorization: Bearer $OPENROUTER_API_KEY" -H "Content-Type: application/json" -d '{"model":"google/gemini-2.5-flash","messages":[{"role":"user","content":"test"}],"max_tokens":10}' \ https://openrouter.ai/api/v1/chat/completions ``` Result: ✅ Returns successful completion with generated text ### Free Model Test ```bash curl -H "Authorization: Bearer $OPENROUTER_API_KEY" -H "Content-Type: application/json" -d '{"model":"meta-llama/llama-3.3-70b-instruct:free","messages":[{"role":"user","content":"test"}],"max_tokens":10}' \ https://openrouter.ai/api/v1/chat/completions ``` Result: ✅ Also works (when not rate-limited) ### Invalid Key Test ```bash curl -H "Authorization: Bearer invalid-key" -H "Content-Type: application/json" -d '{"model":"google/gemini-2.5-flash","messages":[{"role":"user","content":"test"}],"max_tokens":10}' \ https://openrouter.ai/api/v1/chat/completions ``` Result: ❌ Returns authentication error (as expected) ## OpenCode Debug Logs OpenCode successfully finds and initializes the model: INFO service=provider providerID=openrouter modelID=google/gemini-2.5-flash found INFO service=provider status=completed duration=47 providerID=openrouter getSDK But then fails with: ERROR service=session error={“error”:{“name”:“AI_APICallError”,…}} ## Key Findings 1. API key is valid — Direct OpenRouter API calls work perfectly 2. OpenCode detects credentials — Shows in opencode auth list 3. Model is found — OpenCode logs show successful model initialization 4. Request fails in OpenCode — Same API key/model that works directly fails in OpenCode ## Related Issues • #1631: AI_APICallError: No auth credentials found • #604: AI_APICallError: Not Found • #1002: No endpoints found that support tool use ## Conclusion This suggests OpenCode is not properly constructing API requests to OpenRouter, despite having valid credentials and successfully initializing the provider. The “User not found” error is misleading — the user/API key is valid, but something in OpenCode’s request formatting is causing OpenRouter to reject the authentication.
yindo closed this issue 2026-02-16 17:31:13 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Aug 25, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #1631: AI_APICallError: No auth credentials found - Similar authentication issue with OpenRouter where credentials are provided but not recognized
  • #604: AI_APICallError: Not Found - OpenRouter model authentication error despite proper configuration
  • #915: OpenRouter AI_APICallError: Provider returned error - Similar "Provider returned error" with OpenRouter models
  • #1002: OpenRouter Error - AI_APICallError with OpenRouter about endpoints not supporting tool use, but shows similar authentication/API call failures

These issues all involve OpenRouter API call failures despite having valid credentials and proper configuration. The symptoms are very similar - OpenCode detects the credentials but fails when making actual API calls.

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Aug 25, 2025): This issue might be a duplicate of existing issues. Please check: - #1631: AI_APICallError: No auth credentials found - Similar authentication issue with OpenRouter where credentials are provided but not recognized - #604: AI_APICallError: Not Found - OpenRouter model authentication error despite proper configuration - #915: OpenRouter AI_APICallError: Provider returned error - Similar "Provider returned error" with OpenRouter models - #1002: OpenRouter Error - AI_APICallError with OpenRouter about endpoints not supporting tool use, but shows similar authentication/API call failures These issues all involve OpenRouter API call failures despite having valid credentials and proper configuration. The symptoms are very similar - OpenCode detects the credentials but fails when making actual API calls. Feel free to ignore if none of these address your specific case.
Author
Owner

@innersanctumtech commented on GitHub (Aug 25, 2025):

Thanks for the review! I checked those related issues, and while they share the OpenRouter integration problem pattern, mine has a distinct error
message:

My issue: AI_APICallError: User not found (HTTP 401)
Other issues:

  • #1631: No auth credentials found
  • #604: Not Found
  • #915: Provider returned error name=UnknownError
  • #1002: No endpoints found that support tool use

The key difference is that my direct curl tests prove the API key works perfectly with OpenRouter's API, but OpenCode fails with the specific "User
not found" error. This suggests a different root cause in how OpenCode constructs the authentication headers.

I'm keeping this open as a separate issue since:

  1. Different error message indicates different failure point
  2. Direct API validation proves credentials work (unlike some other issues)
  3. This specific "User not found" variant isn't documented in existing issues

This will help track the specific authentication header construction problem vs. the other credential detection/provider issues.

@innersanctumtech commented on GitHub (Aug 25, 2025): Thanks for the review! I checked those related issues, and while they share the OpenRouter integration problem pattern, mine has a distinct error message: My issue: AI_APICallError: User not found (HTTP 401) Other issues: - #1631: No auth credentials found - #604: Not Found - #915: Provider returned error name=UnknownError - #1002: No endpoints found that support tool use The key difference is that my direct curl tests prove the API key works perfectly with OpenRouter's API, but OpenCode fails with the specific "User not found" error. This suggests a different root cause in how OpenCode constructs the authentication headers. I'm keeping this open as a separate issue since: 1. Different error message indicates different failure point 2. Direct API validation proves credentials work (unlike some other issues) 3. This specific "User not found" variant isn't documented in existing issues This will help track the specific authentication header construction problem vs. the other credential detection/provider issues.
Author
Owner

@rekram1-node commented on GitHub (Aug 25, 2025):

@innersanctumtech I can run:

OPENROUTER_API_KEY=*** opencode run "hello" -m "openrouter/google/gemini-2.5-flash"

just fine, can you try running it in another directory? opencode does read in .env files too maybe you have OPENROUTER_API_KEY set in .env?

@rekram1-node commented on GitHub (Aug 25, 2025): @innersanctumtech I can run: ``` OPENROUTER_API_KEY=*** opencode run "hello" -m "openrouter/google/gemini-2.5-flash" ``` just fine, can you try running it in another directory? opencode does read in .env files too maybe you have `OPENROUTER_API_KEY` set in .env?
Author
Owner

@innersanctumtech commented on GitHub (Aug 25, 2025):

@innersanctumtech I can run:

OPENROUTER_API_KEY=*** opencode run "hello" -m "openrouter/google/gemini-2.5-flash"

just fine, can you try running it in another directory? opencode does read in .env files too maybe you have OPENROUTER_API_KEY set in .env?

Searched across my main folders for and .env file and indeed I had one on ~ w an OpenAI key that was sourced in every shell.

I have commented out the openAI key line. And also commented out the line that was calling it from the .zshrc file.

Restarted the terminal completely and tried your recommendation:

OPENROUTER_API_KEY=sk-or-v1-4a7***************5b3 opencode run "hello" -m "openrouter/google/gemini-2.5-flash"
Error: AI_APICallError: User not found.

Error remains.

Image
@innersanctumtech commented on GitHub (Aug 25, 2025): > [@innersanctumtech](https://github.com/innersanctumtech) I can run: > > ``` > OPENROUTER_API_KEY=*** opencode run "hello" -m "openrouter/google/gemini-2.5-flash" > ``` > > just fine, can you try running it in another directory? opencode does read in .env files too maybe you have `OPENROUTER_API_KEY` set in .env? Searched across my main folders for and .env file and indeed I had one on ~ w an OpenAI key that was sourced in every shell. I have commented out the openAI key line. And also commented out the line that was calling it from the .zshrc file. Restarted the terminal completely and tried your recommendation: ``` OPENROUTER_API_KEY=sk-or-v1-4a7***************5b3 opencode run "hello" -m "openrouter/google/gemini-2.5-flash" Error: AI_APICallError: User not found. ```` Error remains. <img width="756" height="81" alt="Image" src="https://github.com/user-attachments/assets/e683b190-fa8e-456f-a859-29a78c1d6255" />
Author
Owner

@rekram1-node commented on GitHub (Aug 25, 2025):

and to confirm there is no api key for openrouter in your auth file already right?

in ~/.local/share/opencode/auth.json

@rekram1-node commented on GitHub (Aug 25, 2025): and to confirm there is no api key for openrouter in your auth file already right? in ~/.local/share/opencode/auth.json
Author
Owner

@innersanctumtech commented on GitHub (Aug 25, 2025):

and to confirm there is no api key for openrouter in your auth file already right?

in ~/.local/share/opencode/auth.json

yes, it had an API key there (the same one as above), which I removed. Though 'opencode auth list' still shows to have a key there.

Image
@innersanctumtech commented on GitHub (Aug 25, 2025): > and to confirm there is no api key for openrouter in your auth file already right? > > in ~/.local/share/opencode/auth.json yes, it had an API key there (the same one as above), which I removed. Though 'opencode auth list' still shows to have a key there. <img width="477" height="655" alt="Image" src="https://github.com/user-attachments/assets/16f458ed-29b8-4f92-9b57-d325b76c4052" />
Author
Owner

@rekram1-node commented on GitHub (Aug 26, 2025):

hmm I can't replicate

maybe worth doing just in case but also try clearing the provider cache too if you don't mind (do this first):
rm -rf ~/.cache/opencode

can you do an opencode run with the --print-logs flag and show me output?

@rekram1-node commented on GitHub (Aug 26, 2025): hmm I can't replicate maybe worth doing just in case but also try clearing the provider cache too if you don't mind (do this first): rm -rf ~/.cache/opencode can you do an opencode run with the `--print-logs` flag and show me output?
Author
Owner

@JamesJosephFinn commented on GitHub (Sep 3, 2025):

@rekram1-node an unrelated issue:

  1. Aliases for slash commands not working (e.g. /q for /exit, /continue for /sessions, etc.)

Please let me know if I should open a separate issue.

@JamesJosephFinn commented on GitHub (Sep 3, 2025): @rekram1-node an unrelated issue: 1. Aliases for slash commands not working (e.g. `/q` for `/exit`, `/continue` for `/sessions`, etc.) Please let me know if I should open a separate issue.
Author
Owner

@rekram1-node commented on GitHub (Sep 3, 2025):

separate issue would be amazing @JamesJosephFinn

@rekram1-node commented on GitHub (Sep 3, 2025): separate issue would be amazing @JamesJosephFinn
Author
Owner

@mustafamagdy commented on GitHub (Sep 13, 2025):

hmm I can't replicate

maybe worth doing just in case but also try clearing the provider cache too if you don't mind (do this first): rm -rf ~/.cache/opencode

can you do an opencode run with the --print-logs flag and show me output?

I did run it with --print-logs, here is the logs:

opencode --print-logs ✔ │ 17:53:11 INFO 2025-09-13T14:53:15 +62ms service=default version=0.7.9 args=["--print-logs"] opencode INFO 2025-09-13T14:53:15 +1ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:15 +5ms service=config path=/Users/myusername/.config/opencode/config.json loading INFO 2025-09-13T14:53:15 +2ms service=config path=/Users/myusername/.config/opencode/opencode.json loading INFO 2025-09-13T14:53:15 +1ms service=config path=/Users/myusername/.config/opencode/opencode.jsonc loading INFO 2025-09-13T14:53:15 +2ms service=plugin path=opencode-copilot-auth@0.0.2 loading plugin INFO 2025-09-13T14:53:15 +6ms service=plugin path=opencode-anthropic-auth@0.0.2 loading plugin INFO 2025-09-13T14:53:15 +19ms service=bus type=* subscribing INFO 2025-09-13T14:53:15 +0ms service=bus type=session.updated subscribing INFO 2025-09-13T14:53:15 +0ms service=bus type=message.updated subscribing INFO 2025-09-13T14:53:15 +0ms service=bus type=message.part.updated subscribing INFO 2025-09-13T14:53:15 +0ms service=format init INFO 2025-09-13T14:53:15 +0ms service=bus type=file.edited subscribing INFO 2025-09-13T14:53:15 +1ms service=lsp serverIds=typescript, vue, eslint, gopls, ruby-lsp, pyright, elixir-ls, zls, csharp, rust, clangd, svelte enabled LSP servers INFO 2025-09-13T14:53:15 +1ms service=models.dev file={} refreshing INFO 2025-09-13T14:53:15 +3ms service=provider init INFO 2025-09-13T14:53:15 +1ms service=provider providerID=openai found INFO 2025-09-13T14:53:15 +0ms service=provider providerID=opencode found INFO 2025-09-13T14:53:15 +0ms service=provider providerID=zhipuai found INFO 2025-09-13T14:53:15 +3ms service=default cmd=["/Users/myusername/.cache/opencode/tui/tui-zjb5j0e3."] tui INFO 2025-09-13T14:53:16 +79ms service=server method=GET path=/agent request INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +2ms service=server duration=2 response INFO 2025-09-13T14:53:16 +1ms service=server method=GET path=/project/current request INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +0ms service=server duration=0 response INFO 2025-09-13T14:53:16 +0ms service=server method=GET path=/path request INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +0ms service=server duration=0 response INFO 2025-09-13T14:53:16 +3ms service=server method=GET path=/config request INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +0ms service=server duration=0 response INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +8ms service=server method=GET path=/command request INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +0ms service=server duration=0 response INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +1ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +0ms service=tui commands={"agent_cycle":{},"agent_cycle_reverse":{},"agent_list":{},"app_exit":{},"app_help":{},"editor_open":{},"input_clear":{},"input_newline":{},"input_paste":{},"input_submit":{},"messages_copy":{},"messages_first":{},"messages_half_page_down":{},"messages_half_page_up":{},"messages_last":{},"messages_page_down":{},"messages_page_up":{},"messages_redo":{},"messages_undo":{},"model_cycle_recent":{},"model_cycle_recent_reverse":{},"model_list":{},"project_init":{},"session_child_cycle":{},"session_child_cycle_reverse":{},"session_compact":{},"session_export":{},"session_interrupt":{},"session_list":{},"session_new":{},"session_share":{},"session_timeline":{},"session_unshare":{},"theme_list":{},"thinking_blocks":{},"tool_details":{}} Loaded commands INFO 2025-09-13T14:53:16 +1ms service=server method=GET path=/file/status request INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +0ms service=server duration=0 response INFO 2025-09-13T14:53:16 +5ms service=server method=GET path=/event request INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +0ms service=server event connected INFO 2025-09-13T14:53:16 +2ms service=bus type=* subscribing INFO 2025-09-13T14:53:16 +1ms service=server duration=3 response INFO 2025-09-13T14:53:16 +1ms service=server method=GET path=/tui/control/next request INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +0ms service=server method=GET path=/config/providers request INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +1ms service=server duration=1 response INFO 2025-09-13T14:53:16 +1ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:22 +2166ms service=bus type=* unsubscribing INFO 2025-09-13T14:53:22 +0ms service=server event disconnected

@mustafamagdy commented on GitHub (Sep 13, 2025): > hmm I can't replicate > > maybe worth doing just in case but also try clearing the provider cache too if you don't mind (do this first): rm -rf ~/.cache/opencode > > can you do an opencode run with the `--print-logs` flag and show me output? I did run it with --print-logs, here is the logs: `opencode --print-logs ✔ │ 17:53:11 INFO 2025-09-13T14:53:15 +62ms service=default version=0.7.9 args=["--print-logs"] opencode INFO 2025-09-13T14:53:15 +1ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:15 +5ms service=config path=/Users/myusername/.config/opencode/config.json loading INFO 2025-09-13T14:53:15 +2ms service=config path=/Users/myusername/.config/opencode/opencode.json loading INFO 2025-09-13T14:53:15 +1ms service=config path=/Users/myusername/.config/opencode/opencode.jsonc loading INFO 2025-09-13T14:53:15 +2ms service=plugin path=opencode-copilot-auth@0.0.2 loading plugin INFO 2025-09-13T14:53:15 +6ms service=plugin path=opencode-anthropic-auth@0.0.2 loading plugin INFO 2025-09-13T14:53:15 +19ms service=bus type=* subscribing INFO 2025-09-13T14:53:15 +0ms service=bus type=session.updated subscribing INFO 2025-09-13T14:53:15 +0ms service=bus type=message.updated subscribing INFO 2025-09-13T14:53:15 +0ms service=bus type=message.part.updated subscribing INFO 2025-09-13T14:53:15 +0ms service=format init INFO 2025-09-13T14:53:15 +0ms service=bus type=file.edited subscribing INFO 2025-09-13T14:53:15 +1ms service=lsp serverIds=typescript, vue, eslint, gopls, ruby-lsp, pyright, elixir-ls, zls, csharp, rust, clangd, svelte enabled LSP servers INFO 2025-09-13T14:53:15 +1ms service=models.dev file={} refreshing INFO 2025-09-13T14:53:15 +3ms service=provider init INFO 2025-09-13T14:53:15 +1ms service=provider providerID=openai found INFO 2025-09-13T14:53:15 +0ms service=provider providerID=opencode found INFO 2025-09-13T14:53:15 +0ms service=provider providerID=zhipuai found INFO 2025-09-13T14:53:15 +3ms service=default cmd=["/Users/myusername/.cache/opencode/tui/tui-zjb5j0e3."] tui INFO 2025-09-13T14:53:16 +79ms service=server method=GET path=/agent request INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +2ms service=server duration=2 response INFO 2025-09-13T14:53:16 +1ms service=server method=GET path=/project/current request INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +0ms service=server duration=0 response INFO 2025-09-13T14:53:16 +0ms service=server method=GET path=/path request INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +0ms service=server duration=0 response INFO 2025-09-13T14:53:16 +3ms service=server method=GET path=/config request INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +0ms service=server duration=0 response INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +8ms service=server method=GET path=/command request INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +0ms service=server duration=0 response INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +1ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +0ms service=tui commands={"agent_cycle":{},"agent_cycle_reverse":{},"agent_list":{},"app_exit":{},"app_help":{},"editor_open":{},"input_clear":{},"input_newline":{},"input_paste":{},"input_submit":{},"messages_copy":{},"messages_first":{},"messages_half_page_down":{},"messages_half_page_up":{},"messages_last":{},"messages_page_down":{},"messages_page_up":{},"messages_redo":{},"messages_undo":{},"model_cycle_recent":{},"model_cycle_recent_reverse":{},"model_list":{},"project_init":{},"session_child_cycle":{},"session_child_cycle_reverse":{},"session_compact":{},"session_export":{},"session_interrupt":{},"session_list":{},"session_new":{},"session_share":{},"session_timeline":{},"session_unshare":{},"theme_list":{},"thinking_blocks":{},"tool_details":{}} Loaded commands INFO 2025-09-13T14:53:16 +1ms service=server method=GET path=/file/status request INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +0ms service=server duration=0 response INFO 2025-09-13T14:53:16 +5ms service=server method=GET path=/event request INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +0ms service=server event connected INFO 2025-09-13T14:53:16 +2ms service=bus type=* subscribing INFO 2025-09-13T14:53:16 +1ms service=server duration=3 response INFO 2025-09-13T14:53:16 +1ms service=server method=GET path=/tui/control/next request INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +0ms service=server method=GET path=/config/providers request INFO 2025-09-13T14:53:16 +0ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:16 +1ms service=server duration=1 response INFO 2025-09-13T14:53:16 +1ms service=project directory=/Users/myusername/Home/demos/test2 fromDirectory INFO 2025-09-13T14:53:22 +2166ms service=bus type=* unsubscribing INFO 2025-09-13T14:53:22 +0ms service=server event disconnected`
Author
Owner

@rekram1-node commented on GitHub (Sep 13, 2025):

@mustafamagdy are you having this issue? if so maybe try:

opencode run "hello" --print-logs 

and add the --model flag too with openrouter/

being any openrouter model

@rekram1-node commented on GitHub (Sep 13, 2025): @mustafamagdy are you having this issue? if so maybe try: ``` opencode run "hello" --print-logs ``` and add the --model flag too with openrouter/<some-model> <some-model> being any openrouter model
Author
Owner

@blankbash commented on GitHub (Sep 26, 2025):

Hope this helps

The "AI_APICallError: No auth credentials found" error occurs because the environment variable name OPENROUTER_API_KEY is too generic MAY conflict with internal naming patterns. Generic names can be intercepted by other providers' fallback mechanisms or clash with the system's own namespace resolution.

The solution is to use a more specific variable name like OPENROUTER_KEY. By updating your environment variable and configuration to use this distinct name, you avoid the internal conflicts that prevented the credentials from being recognized, resolving the authentication error.

Worked on my machine 🙃

@blankbash commented on GitHub (Sep 26, 2025): **Hope this helps** The "AI_APICallError: No auth credentials found" error occurs because the environment variable name OPENROUTER_API_KEY is too generic MAY conflict with internal naming patterns. Generic names can be intercepted by other providers' fallback mechanisms or clash with the system's own namespace resolution. The solution is to use a more specific variable name like OPENROUTER_KEY. By updating your environment variable and configuration to use this distinct name, you avoid the internal conflicts that prevented the credentials from being recognized, resolving the authentication error. Worked on my machine 🙃
Author
Owner

@rekram1-node commented on GitHub (Dec 27, 2025):

[automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!

@rekram1-node commented on GitHub (Dec 27, 2025): [automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1488