Run Python or Node.js code
Runs a short Python 3.12 or Node.js 22 program in a fresh sandbox, with store files in /input; files it writes come back to the store.
$0.005 for a run under 50 seconds
From your agent’s balance. A call that fails costs nothing.
An example
Take the orders export and work out which fabrics sold best last quarter, with a chart.
Your agent callscode_run$0.005 for a run under 50 seconds
The example business is Halverson Cycle & Repair, a bike shop with a repair workshop in Portland, Oregon. The reply is the one the tool really gives.
{
"language": "python",
"files": [
"4e6a8c0e-2a4c-4e8a-9c2e-6a8c0e2a4c7e"
],
"code": "import pandas as pd\n\norders = pd.read_csv(\"/input/orders-q3.csv\")\nby_fabric = orders.groupby(\"fabric\")[\"total\"].sum().sort_values(ascending=False)\nby_fabric.to_csv(\"fabrics-q3.csv\")\nby_fabric.head(8).plot.barh().get_figure().savefig(\"fabrics-q3.png\")\nprint(by_fabric.head(5))"
}Use it when
A job needs real computation: sums over a CSV, a chart, reshaping a spreadsheet.
- For rows of a table filtered and sorted, use
rows_query. - For a chart for a person to look at, use
view_show.
What it does
Run a short program in a fresh sandbox: Python 3.12 (pandas, numpy, scipy, matplotlib, openpyxl, xlsxwriter, pillow, pypdf, python-docx) or Node.js 22 (date-fns, csv-parse, csv-stringify, lodash). Files from the store are in /input (by their names); anything the program writes in its working folder comes back as new files in the store. One CPU, 1 GB of memory, no network (fetch data first with web_read or files_upload). The reply has stdout, stderr (each up to 64 KB), the exit code and the saved files.
What comes back
exit_code, timed_out, duration_ms, stdout and stderr (each up to 64 KB), and files: the new files in the store with their file_ids and download links. Every reply also carries cost_usd and balance_usd.
Inputs
| Name | Type | What it is |
|---|---|---|
languageRequired | string | One of: python,node. |
codeRequired | string | The whole program. 1 to 200,000 characters. |
files | array of strings | file_ids to put in /input. Up to 10 items. |
stdin | string | Up to 1,048,576 characters. |
timeout_seconds | integer | 1 to 300. Default: 60. |
The call
Over MCP, call code_run on https://api.conecto.chat/mcp/code. Over REST:
curl -X POST https://api.conecto.chat/v1/tools/code_run \
-H "Authorization: Bearer $CONECTO_KEY" \
-H "Content-Type: application/json" \
-d '{"language":"python","files":["4e6a8c0e-2a4c-4e8a-9c2e-6a8c0e2a4c7e"],"code":"import pandas as pd\n\norders = pd.read_csv(\"/input/orders-q3.csv\")\nby_fabric = orders.groupby(\"fabric\")[\"total\"].sum().sort_values(ascending=False)\nby_fabric.to_csv(\"fabrics-q3.csv\")\nby_fabric.head(8).plot.barh().get_figure().savefig(\"fabrics-q3.png\")\nprint(by_fabric.head(5))"}'When it refuses
A refused call costs nothing and says what to do next.
| Code | When | What to do |
|---|---|---|
invalid_input400 | language is not python or node, the code or stdin is too long, more than 10 files go in, or the sandbox refused the job. | Fix what the message names. |
not_found404 | A file_id is not a file in the store. | Find the files with files_list. |
too_large413 | The files that go in are over 20 MB together, or a file written is over 25 MB. | Send fewer or smaller files. |
storage_full409 | The file store has no room for the files the program wrote. | Delete files with files_delete, or add room with files_add_storage. |
not_switched_on503 | Running code is not switched on yet. | Try again later; nothing was charged. |
busy503 | The sandbox is busy. | Try again in a minute; nothing was charged. |
sandbox_unavailable503 | The sandbox is not available or did not answer. | Try again later; nothing was charged. |
More Code tools
All 1 toolGive this to your agent.
Set up Conecto from https://conecto.chat/SKILL.md