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

# Code Block

> Run Python code securely during your flow's execution

The Code Block allows you to run Python code securely during your flow's execution using Azure Code Interpreter. This block provides a safe and isolated environment for executing custom Python code. Common use cases include:

* Performing complex calculations
* Implementing custom data processing logic
* Using Python libraries and functions
* Data transformation and analysis

<Note>
  The Code Block only supports Python code execution.
</Note>

<Frame>
  <img src="https://mintcdn.com/odella/MNHyQg3-ZFMTYSp3/block-reference/assets/code_light.png?fit=max&auto=format&n=MNHyQg3-ZFMTYSp3&q=85&s=bfabc6ff33df334aee562132bae18b9c" alt="Code Block Screenshot" className="block dark:hidden" width="688" height="296" data-path="block-reference/assets/code_light.png" />

  <img src="https://mintcdn.com/odella/MNHyQg3-ZFMTYSp3/block-reference/assets/code_dark.png?fit=max&auto=format&n=MNHyQg3-ZFMTYSp3&q=85&s=e5ede6f60c378b05cfd458b3b618ec95" alt="Code Block Screenshot" className="hidden dark:block" width="700" height="292" data-path="block-reference/assets/code_dark.png" />
</Frame>

## Inputs

<ParamField path="input1" type="any" required={false}>
  Default input port. Input names are configurable and each creates a corresponding port. Values are accessible in your Python code via the `inputs` dictionary with typed values (e.g., `inputs["input1"]["type"]`, `inputs["input1"]["value"]`).
</ParamField>

## Outputs

<ResponseField name="output1" type="any">
  Default output port. Output names are configurable and each creates a corresponding port. The code must return a dictionary with typed values matching the configured output names (e.g., `{"output1": {"type": "string", "value": "result"}}`).
</ResponseField>

## Editor Settings

<ParamField path="Inputs" type="stringList" default={["input1"]}>
  List of input names. Each name creates an input port on the block. Names are sanitized to be valid Python identifiers (only alphanumeric and underscore characters).
</ParamField>

<ParamField path="Outputs" type="stringList" default={["output1"]}>
  List of output names. Each name creates an output port on the block. The code must return values for all configured outputs.
</ParamField>

<ParamField path="AI Assist" type="custom">
  An AI assistant to help write and modify your code.
</ParamField>

<ParamField path="Code" type="code" language="python">
  The Python code to execute. Must include a `main(inputs)` function that processes the inputs and returns a dictionary of outputs. Default template:

  ```python theme={"system"}
  def main(inputs):
    return {
      "output1": {
        "type": inputs["input1"]["type"],
        "value": inputs["input1"]["value"]
      }
    }
  ```
</ParamField>

## Code Structure

Your code must:

* Define a `main(inputs)` function
* Access inputs through the `inputs` dictionary where each input has `type` and `value` properties
* Return a dictionary with output names matching those configured in settings
* Each output must have `type` and `value` properties
