Code Interpreter API broken — x-api-key no longer sent after JWT minting refactor (#13028) #13114
Replies: 2 comments
|
This is a planned deprecation, I'm working on releasing the open-source version of this soon. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
What happened?
Hi,
I'm a paying Code Interpreter API subscriber and ran into a regression on the latest
mainbranch where code execution no longer works with the documentedLIBRECHAT_CODE_API_KEYsetup.Commit that introduced the issue:
c67e2b54dca133a8faf3d37f1e54ee993e6bf153(PR #13028, "🔐 feat: Mint Code API Auth Tokens", May 9, 2026)What's happening:
After pulling
main, code execution requests fail with:Root cause:
The new
getCodeApiAuthHeaders()inpackages/api/src/auth/codeapi.tsreturns{}when JWT auth isn't enabled:All the call sites (
crud.js,process.js,ToolService.js,handleTools.js) were switched to use only these headers, so the previousx-api-keyheader fromLIBRECHAT_CODE_API_KEYis no longer being sent anywhere.Setting
CODEAPI_AUTH_PROVIDER=legacy-api-keydoesn't help either —isCodeApiJwtAuthEnabled()returns false in that case, so the function still returns empty headers.Expected behavior:
Per the official docs (https://www.librechat.ai/docs/features/code_interpreter), the documented setup is to set
LIBRECHAT_CODE_API_KEYin.envand the request should include thex-api-keyheader. Subscription users like me rely on this working out of the box.Suggested fix:
In
getCodeApiAuthHeaders(), fall back to{ 'x-api-key': process.env.LIBRECHAT_CODE_API_KEY }when JWT auth isn't enabled andLIBRECHAT_CODE_API_KEYis set. This preserves backwards compatibility for subscription users while still supporting the new JWT auth for Enterprise self-hosted instances.Happy to test a fix or open a PR if useful.
Thanks for all the work on LibreChat!
Version Information
$ docker images | grep librechat
librechat latest 28dad5f0fa3a 2026-05-13 12:50:08 +0000 UTC
registry.librechat.ai/danny-avila/librechat-rag-api-dev-lite latest 31122c5f83ea 2026-04-24 04:45:28 +0000 UTC
ghcr.io/clickhouse/librechat-admin-panel latest 9542874536e7 2026-04-17 17:43:08 +0000 UTC
Steps to Reproduce
mainbranch (any commit including c67e2b5 or later, merged May 9, 2026)..env, set your paid Code Interpreter API subscription key as documented:LIBRECHAT_CODE_API_KEY=sk-lc-code01_xxxxxxxxxxxxxxxxxxx
docker compose build && docker compose up -d)."CodeAPI request failed: POST https://api.librechat.ai/v1/exec returned 401, body: {"error":"API key is required"}"
Expected: code executes successfully using the API key from
.envas documented at https://www.librechat.ai/docs/features/code_interpreterActual: 401 because the
x-api-keyheader is no longer being sent — the newgetCodeApiAuthHeaders()returns{}unless JWT auth is configured (which requires keys not available to subscription users).Verified by reverting to a commit before c67e2b5 (e.g., v0.8.5 tag) — code execution works again with the same
.env.What browsers are you seeing the problem on?
Chrome
Relevant log output
error-2026-05-13.log: {"level":"error","message":"[ON_TOOL_EXECUTE] Tool bash_tool error: Execution error:\n\nCodeAPI request failed: POST https://api.librechat.ai/v1/exec returned 401, body: {\"error\":\"API key is required\"}","stack":"Error: Execution error:\n\nCodeAPI request failed: POST https://api.librechat.ai/v1/exec returned 401, body: {\"error\":\"API key is required\"}\n at tools.tool.name (/app/node_modules/@librechat/agents/dist/cjs/tools/BashExecutor.cjs:159:19)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async /app/node_modules/@langchain/core/dist/tools/index.cjs:307:22","timestamp":"2026-05-13T13:13:23.787Z"}Screenshots
No response
Code of Conduct
All reactions