DIAL Code Interpreter API
This reference distinguishes Core 0.49.4's public interpreter session API from Code Interpreter 0.2.0's private container API. It is for platform engineers verifying the configured interpreter. Quick Apps calls the Core API, which manages session ownership, workload lifecycle, and file transfers.
Core session API
Paths below are relative to the DIAL Core base URL and require DIAL authentication with an API key or bearer token. Opening a session and executing code also check access.createCodeAppRoles; the check passes when the setting is unset or the request carries a per-request key.
| Method | Path | Input | Response |
|---|---|---|---|
POST | /v1/ops/code_interpreter/open_session | JSON with optional sessionId; {} generates an ID | JSON containing sessionId |
POST | /v1/ops/code_interpreter/get_session | sessionId | Session metadata visible to the caller |
POST | /v1/ops/code_interpreter/close_session | sessionId | Closed session's public metadata |
POST | /v1/ops/code_interpreter/execute_code | code, optional sessionId, inputFiles, and outputFiles | Execution result |
POST | /v1/ops/code_interpreter/upload_file | Multipart file and required session_id query parameter | File path and size |
POST | /v1/ops/code_interpreter/download_file | sessionId and path | File bytes |
POST | /v1/ops/code_interpreter/list_files | sessionId | JSON files array |
POST | /v1/ops/code_interpreter/transfer_input_file | sessionId, DIAL sourceUrl, and session targetPath | File path and size |
POST | /v1/ops/code_interpreter/transfer_output_file | sessionId, session sourcePath, and DIAL targetUrl | DIAL file metadata |
The released Core controller defines these operations. Private deployment URLs and deployment IDs are removed from session responses.
Execution and session behavior
| Field | Required | Description |
|---|---|---|
code | Yes | Python source string. |
sessionId | No | Existing session ID. Without it, Core opens a temporary session and closes it after the execution request completes. |
inputFiles | No | Files copied from DIAL storage before execution, using sourceUrl and targetPath. Core supplies the active session ID. |
outputFiles | No | Files copied into DIAL storage after execution, using sourcePath and targetUrl. Core supplies the active session ID. |
With an explicit session, subsequent calls reuse kernel variables and files. Idle sessions expire according to Core settings. File transfers check read or write access to the corresponding DIAL resource. See execution lifecycle and file authorization.
Example single calculation through Core:
curl --request POST \
'https://<DIAL_HOST>/v1/ops/code_interpreter/execute_code' \
--header 'Api-Key: <DIAL_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{"code":"print(6 * 7)"}'
The successful result has this shape:
{
"status": "SUCCESS",
"stdout": "42\n",
"stderr": "",
"result": "",
"display": []
}
Core closes this request's temporary session. A stateful caller first opens a session with {} and passes its returned sessionId on later requests:
{"sessionId": "<SESSION_ID>", "code": "values = [12, 18, 24]; print(sum(values) / len(values))"}
Execution response
| Field | Description |
|---|---|
status | SUCCESS or FAILURE. A Python exception can produce HTTP 200 with FAILURE; the caller must inspect this field. |
stdout | Captured standard output with ANSI escapes removed. |
stderr | Captured standard error and Python traceback content, with ANSI escapes removed. |
result | Jupyter execution-result MIME data when present; otherwise an empty string in the interpreter implementation. |
display | A list of Jupyter display-data objects, such as image or Plotly MIME data. |
The service does not stream token-by-token output. It waits for execution to finish and returns one result. Sources: response model and kernel message handling.
Core errors
| HTTP status | Meaning |
|---|---|
400 | Invalid JSON or a missing or invalid operation field, such as code or sessionId. |
403 | Interpreter permission is denied, or a DIAL file transfer lacks the required access. |
404 | The requested session or file cannot be found. An idle session may already have expired. |
503 | Core's interpreter or application controller configuration is unavailable. |
500 | Unhandled infrastructure or execution-service failure. |
Core maps errors in CodeInterpreterController. Authentication and gateway limits also apply before these handlers. Full API schemas are in the Unified API specification.
Private container API
These endpoints belong to one running interpreter process on port 8080. They do not create or close sessions and do not accept Core's sessionId field as a session-management mechanism.
| Method | Path | Request | Response |
|---|---|---|---|
GET | /health | None | {"status":"HEALTHY"} |
POST | /execute_code | JSON {"code":"<PYTHON_CODE>"} | Execution result described above |
POST | /upload_file | Multipart field file | {"path":"<RELATIVE_PATH>","size":<BYTES>} |
POST | /download_file | JSON {"path":"<FILE_PATH>"} | application/octet-stream bytes |
POST | /list_files | JSON {}; optional comment is accepted but unused | {"files":[{"path":"<RELATIVE_PATH>","size":<BYTES>}]} |
When SESSION_ID is configured, every operation except /health requires matching x-dial-session-id. That value is Core's private deployment ID in pod-backed mode, not the public session ID. Missing headers return 400; mismatches return 503.
Uploads replace any existing target file. If an upload fails, the target is removed; previous contents are not restored. Uploads exceeding UPLOAD_MAX_SIZE return 413. Missing downloads return 404, and missing or rejected file paths return 400. Request-model validation can return 422. See app.py and request models.
Warning
Direct access bypasses Core's user permissions and resource checks. The interpreter API must remain within the protected execution infrastructure. Its optional session header is not a replacement for user authentication or network isolation.
Further reading
- Interpreter configuration — limits, kernel timeouts, session expiry, and Quick Apps connection
- Quick Apps tools — offer Python calculations to an orchestrator
- App Controller API — the internal workload API used by Core
- Unified API — the OpenAPI specification of DIAL's OpenAI-compatible API