Infery.ai
← All tools

Run Python code

Code

code.run_python

in: anyout: text

Execute Python in a sandboxed runtime.

Pricing

Price
6.25 cr / second

Prices in credits (1 credit = $0.01).

Run Python Code

Execute a Python snippet in an isolated sandbox and return the value of result.

When to use

  • Data transformation — reshape, filter, or aggregate structured data before passing it downstream.
  • Calculations — run numerical or statistical computations without a separate service.
  • Scripted automation — generate or manipulate text, JSON, or binary payloads inline.

Inputs & outputs

Input modalityAny (named variable bindings via vars)
Output modalityText / JSON (the value of result after execution)
Max source length50 000 characters
Max timeout30 seconds

Parameters

ParamRequiredDescription
sourceyesPython source code (1–50 000 chars). Must assign to result.
timeout_secondsnoExecution time limit in seconds (1–30). Default: 5

Input

FieldDescription
varsDictionary of named bindings injected as local variables before execution. Values can be any JSON-serialisable type.

Examples

Add 1 to an input variable

{
  "type": "code.run_python",
  "input": { "vars": { "x": 5 } },
  "params": { "source": "result = x + 1", "timeout_seconds": 5 }
}

Parse and summarise JSON

{
  "type": "code.run_python",
  "input": { "vars": { "data": [1, 2, 3, 4, 5] } },
  "params": { "source": "result = {'sum': sum(data), 'count': len(data)}", "timeout_seconds": 5 }
}

Pricing

Billed per second of sandbox execution time (rounded up to the nearest second). See pricing dashboard for current rates.

Related capabilities

  • code.run_node — execute Node.js code in a sandbox
  • web.search — retrieve live data to process with this capability

Examples

Add 1 to x

{
  "source": "result = x + 1",
  "timeout_seconds": 5
}