Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Code execution

The Code node performs calculations and data transformations with code. Use it when a step must follow explicit rules or return a defined data structure.

Before you start

This guide requires Python or TypeScript programming knowledge. If your task only needs to pass fields or format an answer, start with Map variables and expressions or Structured outputs and templates. Have a connected workflow and know the input fields your function must receive before writing code.

Connect and configure Code

Connect the input, Code, and output nodes.

Input, Code, and Output connections

Decide which values the code must receive and which values later nodes will need.

Open Code settings and select Python or TypeScript.

Code language settings

The function must use the syntax and return format appropriate for the selected language.

Write and run the function

Open the code editor and review the function.

Code function editor

Return useful values explicitly. Printed log messages help with diagnosis but are not a substitute for the returned result.

Run the code and inspect its result, exit code, logs, and error field.

Code result, exit code, logs, and error details

A successful execution should return the expected value without an execution error.

Use the returned values

Insert the required Code result field into the downstream template.

Code result field in a downstream template

Match the expression path to the actual returned object.

Run the complete workflow and inspect Output.

Complete workflow output after code execution

This checks that both code execution and the downstream reference produce the intended result.

Important behavior

Printed messages appear in logs. Return the values that later nodes need from the function.

If a later node reports a missing value, compare its reference with the fields under Code.result.

Last updated

Was this helpful?