Execute code
Runs code in an isolated sandbox and returns its output plus any files
it produced. The call blocks until the run finishes.
Rate limited to 20 requests per 30 s per principal by default
(MAX_REQUESTS / RATE_LIMIT_WINDOW).
With CODEAPI_PERSIST_SESSIONS=true this route (and only this route)
continues the caller's previous run: files left in /mnt/data and, for
Python, the global namespace are restored automatically.
Authorization
BearerAuth EdDSA (Ed25519) JWT minted by LibreChat. Required unless the service
runs with LOCAL_MODE=true or CODEAPI_AUTH_PROVIDER=none.
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/exec" \ -H "Content-Type: application/json" \ -d '{ "lang": "py", "code": "print(sum(range(10)))" }'{ "session_id": "string", "stdout": "string", "stderr": "string", "files": [ { "id": "string", "resource_id": "string", "storage_session_id": "string", "name": "string", "kind": "user", "version": 0 } ], "code": 0, "signal": "string", "message": "string", "status": "string", "wall_time": 0, "session_state_persisted": true, "session_state_restore_failed": true}