Using APIs in a Python Script - Using APIs in a Python Script - 2026.1 English - UG1702

Vitis Reference Guide (UG1702)

Document ID
UG1702
Release Date
2026-06-23
Version
2026.1 English

You need to add the Python package vitis that includes the Python APIs to the Python script. The example below uses the Python APIs in a Python script to manage an AI Engine component.


# Add package: Vitis Python CLI
import vitis

# Create a Vitis client object -
client = vitis.create_client()

# Set Vitis Workspace
client.set_workspace(path=<workspace_location>)

# Create aie component.
aie_test_comp = client.create_aie_component(name = comp_name, platform = <absolute path of platform>, template = "empty_aie_component")

# Import source files to the component
aie_test_comp.import_files(from_loc = <absolute path of source folder>, files = ['graph.cpp', 'graph.h', 'kernels.h', 'include.h', 'classify.cc', 'hb27_2i.cc'])

# Set top file from the imported source
aie_test_comp.update_top_level_file(top_level_file = 'graph.cpp')

# Build component on target Hardware
aie_test_comp.build(target="hw")

# Print component information
aie_test_comp.report()

The following command launches the Vitis Unified IDE, and executes the Python script:

vitis -s aie_comp.py

The vitis -s command manages the Vitis component (for example, creation, building or editing configuration file).

Launch the Vitis IDE. Display the AI Engine components in the workspace using the vitis -w command.

vitis -w <workspace_location>
Vitis creates the AI Engine component and generates the libadf.a file. The component build completes successfully.

To simulate and debug the AI Engine component, refer to the next section.