> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qxlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom code

> Run Python inside a flow with the Custom Code node for the steps no built-in node covers, with the AI builder writing the code for you.

The **Custom Code** node runs Python inside a flow, for the steps no built-in node covers. It sits in the **Workflow Basics** category.

> [!NOTE]
>
> The AI builder can handle this node for you. Describe what the step should do on the **Chat** tab, and it writes the code and sets up its inputs and outputs for you. See [Build with AI](https://docs.qxlabs.com/flows/build-with-ai.md).

## How it works

The code lives in the **Code** field, written as a `process` function that receives the node's inputs and returns its outputs.

The ports on the node come from what is declared. Each row under **Declared Inputs** becomes a field you can wire an earlier node into, and each row under **Declared Outputs** becomes a value later nodes can use. Every row has a name and a type.

![A Custom Code node showing the code editor with declared inputs and outputs](https://mintcdn.com/qx-labs/ZJkiVX6zo-84vXkk/images/flows/nodes/custom-code/custom-code-node-light.png?fit=max\&auto=format\&n=ZJkiVX6zo-84vXkk\&q=85\&s=0921bbc82b1b3f5e5bfd630a5b4f0745)

Two more settings matter when the code does something heavier. **Pip Packages** installs any Python libraries it needs, and **Timeout (seconds)** caps how long it may run before the flow gives up on it.

If you do edit the code by hand, it must return a value for every declared output, and nothing is kept between runs, so treat each run as a fresh start.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.