Code Interpreter
ApiExecutionExecProgrammatic

Execute code that can call tools

POST
/exec/programmatic

Runs code that may pause to call back into caller-provided tools. When the program calls a tool, the response returns status: tool_call_required with a continuation_token and the pending tool_calls; send the results back with that token to resume.

Supports Python and Bash. Persistent sessions do not apply to this route: even with CODEAPI_PERSIST_SESSIONS=true, programmatic runs get a cold workspace and namespace every time.

Authorization

BearerAuth
AuthorizationBearer <token>

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/programmatic" \  -H "Content-Type: application/json" \  -d '{    "code": "string"  }'
{  "status": "tool_call_required",  "continuation_token": "string",  "tool_calls": [    {      "id": "string",      "name": "string",      "arguments": {}    }  ],  "partial_stdout": "string",  "partial_stderr": "string",  "stdout": "string",  "stderr": "string",  "files": [    {      "id": "string",      "resource_id": "string",      "storage_session_id": "string",      "name": "string",      "kind": "user",      "version": 0    }  ],  "session_id": "string",  "tool_calls_made": 0,  "execution_time": 0,  "error": "string",  "error_type": "string"}