from openapi import SDK
with SDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as sdk:
res = sdk.sandbox.run_code(session_id_param="demo-python-20260316", session_id="demo-python-20260316", code="from pathlib import Path; Path('live_check.txt').write_text('ok'); print('code-ran')", session_token="sandbox_test_20260316_4f9c2b1a", runtime="python", cwd=None, env={
}, timeout_seconds=60)
# Handle response
print(res){
"session_id": "demo-python-20260316",
"runtime": "python",
"cwd": "/workspace",
"stdout": "code-ran\n",
"stderr": "",
"exit_code": 0,
"files_changed": [
"live_check.txt"
]
}Ejecutar código fuente en el espacio de trabajo de la sesión utilizando un runtime compatible y devolver el resultado de la ejecución.
from openapi import SDK
with SDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as sdk:
res = sdk.sandbox.run_code(session_id_param="demo-python-20260316", session_id="demo-python-20260316", code="from pathlib import Path; Path('live_check.txt').write_text('ok'); print('code-ran')", session_token="sandbox_test_20260316_4f9c2b1a", runtime="python", cwd=None, env={
}, timeout_seconds=60)
# Handle response
print(res){
"session_id": "demo-python-20260316",
"runtime": "python",
"cwd": "/workspace",
"stdout": "code-ran\n",
"stderr": "",
"exit_code": 0,
"files_changed": [
"live_check.txt"
]
}Gateway auth: send Authorization: Bearer <mka1-api-key>. For multi-user server-side integrations, you can also send X-On-Behalf-Of: <external-user-id>.
¿Esta página le ayudó?