Code

Run Python or Node.js code

code_run · Changes data · Markdown

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.

With these arguments
{
  "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))"
}
What comes back
{
  "exit_code": 0,
  "timed_out": false,
  "duration_ms": 2400,
  "stdout": "fabric\nBoucle Rust    14280\nVelvet Moss    11340\nLinen Sand      6400\nName: total, dtype: int64\n",
  "stderr": "",
  "files": [
    {
      "file_id": "12e74e0e-1ce8-494c-b378-08486a1a9bf1",
      "name": "fabrics-q3.csv",
      "content_type": "text/csv",
      "size": "65 bytes",
      "size_bytes": 65,
      "sha256": "7e62ce9e39088dbade5e32cea77bfaec1fb1c1a78ad63bbbbec04a5df8332710",
      "created_at": "2026-10-14T08:00:00+00:00",
      "download_url": "https://cncto.co/d/12e74e0e-1ce8-494c-b378-08486a1a9bf1?t=eyJmIjoiMTJlNzRlMGUtMWNlOC00OTRjLWIzNzgtMDg0ODZhMWE5YmYxIiwiZXhwIjoxNzkyMDIzMTUzfQ:1xGmbh:r530kLRgRi9orjUJ0sO9zSVOUgbbtH6xdXUWzjRp57g",
      "link_expires_in_hours": 24
    },
    {
      "file_id": "513a788c-0fb6-449b-b290-4f7c14de3170",
      "name": "fabrics-q3.png",
      "content_type": "image/png",
      "size": "1.5 KB",
      "size_bytes": 1487,
      "sha256": "c000989c12dfc6d82675a704e909a7543bdea1fa3a93307a97fb69620e87ffc2",
      "created_at": "2026-10-14T08:00:00+00:00",
      "download_url": "https://cncto.co/d/513a788c-0fb6-449b-b290-4f7c14de3170?t=eyJmIjoiNTEzYTc4OGMtMGZiNi00NDliLWIyOTAtNGY3YzE0ZGUzMTcwIiwiZXhwIjoxNzkyMDIzMTUzfQ:1xGmbh:J4qQ5XS11u7Zt2rhz2K9sIKetkNWsYSD37fAeiER1SA",
      "link_expires_in_hours": 24
    }
  ]
}

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

NameTypeWhat it is
languageRequiredstringOne of: python,node.
codeRequiredstringThe whole program. 1 to 200,000 characters.
filesarray of stringsfile_ids to put in /input. Up to 10 items.
stdinstringUp to 1,048,576 characters.
timeout_secondsinteger1 to 300. Default: 60.

The call

Over MCP, call code_run on https://api.conecto.chat/mcp/code. Over REST:

Terminal
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.

CodeWhenWhat to do
invalid_input400language 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_found404A file_id is not a file in the store.Find the files with files_list.
too_large413The files that go in are over 20 MB together, or a file written is over 25 MB.Send fewer or smaller files.
storage_full409The 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_on503Running code is not switched on yet.Try again later; nothing was charged.
busy503The sandbox is busy.Try again in a minute; nothing was charged.
sandbox_unavailable503The sandbox is not available or did not answer.Try again later; nothing was charged.

More Code tools

All 1 tool

    Give this to your agent.

    Set up Conecto from https://conecto.chat/SKILL.md