Build DX-M1 Inference Apps With an AI Coding Agent

Build Python or C++ inference apps for the DEEPX DX-M1 NPU by describing them to an AI coding agent. Setup, prompts, validation steps, and fixes.

With agent-driven development for DX-APP, you describe the inference app you want in plain English and an AI coding agent builds it for the DEEPX DX-M1 NPU. The agent writes the Python or C++ code, registers your .dxnn model, validates the result, and leaves you with scripts to run it.

This guide covers the practical path: setup, your first prompt, the questions the agent asks, what lands on disk, and how to check the app works. It's the companion to our DX-COM guide: DX-COM turns your model into a .dxnn file, and DX-APP turns that file into a running application.


The short version

  1. Open the dx_app project in your AI coding tool.
  2. Tell the agent what to build, for example: "Build a yolo26n person detection app using Python."
  3. Confirm three choices: language and variant, AI task, and model.
  4. Wait while the agent generates and validates the code.
  5. Run bash setup.sh && bash run.sh from the session folder.

Key terms

  • DX-APP is DEEPX's toolkit for building standalone inference applications on the DX-M1.
  • DXNN is DEEPX's compiled model format (.dxnn). The DX-M1 NPU runs these files.
  • Factory is the class that defines how an app prepares inputs and interprets outputs for one model. Every generated app has one.
  • Sync and async describe how the app feeds frames to the NPU: one at a time, or in a pipeline.
  • Postprocessing turns raw model output into results you can use, such as labeled boxes.

Which agent does what

You usually talk to one agent, dx-app-builder. It reads your request and hands the work to a specialist.

AgentWhat it does
dx-app-builderRouter. Classifies your request and dispatches it
dx-python-builderBuilds Python apps in four variants (see Step 3)
dx-cpp-builderBuilds C++ apps using the InferenceEngine API
dx-benchmark-builderBenchmarks and profiles performance
dx-model-managerDownloads, registers, and manages .dxnn models
dx-validatorChecks generated code and framework integrity. Runs automatically after generation

In Claude Code and Cursor, you type the request and routing happens for you. In GitHub Copilot and OpenCode, you can name an agent with @.


Before you start

RequirementDetails
DeviceA Sixfab AI HAT+ or Sixfab Edge AI Expansion Board on a Raspberry Pi 5, or an ALPON X5 AI
OSRaspberry Pi OS Trixie (64-bit). Bookworm also works
Runtime and driverInstalled with the Sixfab quickstart for your device (see below). Only validation levels 4 and 5 need the NPU (see Step 5)
Project folderThe dx_app repository, cloned in Step 1
Python environmentDependencies installed by install.sh. If you use a virtual environment, activate it and make sure PYTHONPATH includes the project root
A modelA .dxnn file, or let the agent download and register one
AI coding agentClaude Code, GitHub Copilot (VS Code), Cursor, OpenCode, or Codex CLI

Have no .dxnn file yet? You have three routes. Ask the agent to download one ("Download yolo26n model for DX-M1"), grab a pre-compiled model from the Sixfab Model Zoo, or compile your own with the DX-COM guide.

Install the runtime first

DX-APP needs the DEEPX runtime and kernel driver on your device. Sixfab packages both, so follow the quickstart for your product and come back here when it's done:

Your deviceQuickstart
Sixfab AI HAT+AI HAT+ quickstart
Sixfab Edge AI Expansion BoardEdge AI Expansion Board quickstart
ALPON X5 AIALPON X5 AI quickstart

Then check that your NPU is visible:

dxrt-cli -s

Expected result: a device report that shows your NPU, the driver and firmware versions, and the PCIe link. If the NPU doesn't show up, see Troubleshooting.

Choose your tool

Each tool loads the project's configuration automatically when you open the folder.

ToolTypeHow you talk to the agent
Claude CodeCLIType your request as normal conversation
CursorIDEType your request as normal conversation
GitHub CopilotVS Code@dx-app-builder "your request", or a specialist agent
OpenCodeCLI@dx-app-builder "your request", or a slash skill such as /dx-agent-app-build-python
Codex CLICLIType your request as normal conversation

Step 1: Get the project and open it

Clone the repository on your device, install its dependencies, and build the sample applications:

git clone https://github.com/DEEPX-AI/dx_app
cd dx_app
./install.sh
./build.sh

install.sh installs the dependencies. build.sh builds the DX-APP applications. Both can take a while on the first run. To see the available options, run ./install.sh --help and ./build.sh --help.

Then start your tool from inside the dx_app folder. Each tool finds its configuration file there.

# Claude Code
claude

# OpenCode
opencode

# Codex CLI
codex

# GitHub Copilot: open the folder in VS Code
code .

# Cursor: open the folder in Cursor
cursor .

If you use a Python virtual environment, activate it in your terminal before you start. The validation scripts need it.


Step 2: Tell the agent what to build

State the task, the model, and the language. These prompts cover the common cases:

You wantPrompt
A Python detection appBuild a yolo26n person detection app using Python
A C++ appBuild a C++ inference app for yolo26n using InferenceEngine
A faster, pipelined appBuild an async high-performance detection app with yolo26n
Pose estimationBuild a pose estimation app with yolo26n-pose
Instance segmentationBuild an instance segmentation app with yolo26n-seg
Image classificationBuild an image classification app with EfficientNet-B0
A model downloadDownload yolo26n model for DX-M1
A check of existing codeValidate the detection app I created

In OpenCode, slash skills such as /dx-agent-app-build-python do the same job. In Copilot, start with @dx-app-builder, or with a specialist like @dx-python-builder.

These are examples. Swap in your own model name and task.


Step 3: Confirm the three choices

Before it writes any code, the agent asks three questions. They're mandatory, and the agent asks them even when your prompt already answers them. Treat them as a confirmation step.

1. Which language and variant?

ChoiceWhat you get
Python: syncOne frame at a time. The simplest app to read and debug
Python: asyncA pipelined app that feeds frames continuously
Python: sync with C++ postprocessingSync app that runs postprocessing in C++ through pybind
Python: async with C++ postprocessingAsync app with C++ postprocessing
C++A native app built on the InferenceEngine API

New to this? Start with Python sync. It's the easiest one to read and the easiest to debug.

2. Which AI task?

Detection, classification, segmentation, or pose estimation. Pick the one that matches your model.

3. Which model?

Name a specific model (for example yolo26n) or ask the agent to recommend one. If the .dxnn file isn't registered yet, dx-model-manager downloads it and records it in model_registry.json.


Step 4: Review what the agent created

Each run gets its own session folder, so runs never overwrite each other:

dx-agent-dev/<session_id>/
├── README.md
├── session.json
├── setup.sh          (mandatory)
├── run.sh            (mandatory)
├── session.log       (mandatory)
└── src/python_example/{task}/{model}/
    ├── __init__.py
    ├── config.json
    ├── {model}_factory.py
    ├── {model}_sync.py
    ├── {model}_async.py
    ├── {model}_sync_cpp_postprocess.py
    └── {model}_async_cpp_postprocess.py

The session ID looks like YYYYMMDD-HHMMSS_<agent>_<model>_<task>, where <agent> is claude, copilot, cursor, or opencode. The agent writes into the project's own src/ folder only when you explicitly ask for production placement.

What each file does

FilePurpose
config.jsonModel path, task type, input dimensions, and label map
{model}_factory.pyDefines how the app prepares inputs, processes outputs, and draws results
{model}_sync.pyEntry point for the synchronous app
{model}_async.pyEntry point for the pipelined async app
{model}_sync_cpp_postprocess.pySync entry point with C++ postprocessing
{model}_async_cpp_postprocess.pyAsync entry point with C++ postprocessing
setup.sh / run.shSet up the environment and launch the app
session.logRecord of what the agent did

Depending on the variant you chose, you may see only some of the entry-point files.


Step 5: Validate the app

The dx-validator agent runs automatically after generation. You can also run the same checks yourself. Validation works as a pyramid of five levels, and each level must pass before the next one counts:

LevelWhat it checksNeeds NPU?
  1. Static
Absolute imports, naming, structure, factory methodsNo
  1. Config
config.json schema, model path, task typesNo
  1. Smoke
--help runs and modules importNo
  1. NPU integration
End-to-end inference on a sample imageYes
  1. Performance
FPS meets the target thresholdsYes

Run the checks from the project root:

# Levels 1-2: static and config checks
python .deepx/scripts/validate_app.py src/python_example/{task}/{model}/

# Levels 1-3: adds smoke tests
python .deepx/scripts/validate_app.py src/python_example/{task}/{model}/ --smoke-test

# Framework integrity
python .deepx/scripts/validate_framework.py

Replace {task} and {model} with your own folder names, for example detection and yolo26n.

Expected result: each level reports pass or fail with the reason. Levels 1 to 3 run on any machine with the environment set up. Levels 4 and 5 need the DX-M1.


Step 6: Run the app

From the session folder:

bash setup.sh && bash run.sh

Expected result: the app loads your model, runs inference on a sample input, and shows or prints the results. For a detection app, that means labeled boxes.

Note: setup.sh changes your environment. Read it first if you want to know what it does.


Editing the generated code

You'll probably want to change what the agent wrote. Two rules keep the app working:

  • Use absolute imports. Relative imports such as from .factory import ... break the app. LLMs default to them, so check generated code for them.
  • Keep all five factory methods. Every factory implements create_preprocessor, create_postprocessor, create_label_map, create_input_config, and create_visualizer. If one is missing, validation fails.

Don't edit the platform files (.github/, .cursor/, .opencode/, CLAUDE.md, AGENTS.md). DEEPX generates them from the .deepx/ folder. To change them, edit the source in .deepx/ and re-run DEEPX's dx-agent-gen generator. A pre-commit hook runs it automatically when you commit.


Troubleshooting

What you seeLikely causeFix
Relative imports in generated codeThe AI model's default habitSwitch to absolute imports
Factory class is missing methodsIncomplete factoryImplement all five factory methods listed above
Model not found at runtimeThe .dxnn path isn't registeredAsk dx-model-manager to download and register it in model_registry.json
NPU not available, or a device errorThe accelerator isn't detectedRun dxrt-cli -s and check that the kernel module is loaded
validate_app.py fails right awayPython path or virtual environment isn't setActivate the virtual environment and set PYTHONPATH to the project root

Still stuck? Ask the agent to debug. It has a debugging skill (/dx-swe-debugging) that finds the cause before it proposes a fix.


Optional skills

You can call these by name in tools that support slash commands, or describe the same intent in plain language.

SkillUse it to
/dx-agent-app-build-pythonBuild a Python app
/dx-agent-app-build-cppBuild a C++ app
/dx-agent-app-build-asyncBuild an async app
/dx-agent-app-model-managementDownload and register models
/dx-agent-app-validateValidate an app
/dx-swe-brainstormPlan before building
/dx-swe-tddValidate each step as you go
/dx-swe-verifyRequire evidence before the agent calls the job done

Next steps


FAQ

What is agent-driven development for DX-APP?

It's a way to build inference apps for the DEEPX DX-M1 NPU by talking to an AI coding agent. You describe the app, and specialist agents generate the code, register the model, validate the result, and write the setup and run scripts.

How is this different from the DX-COM guide?

DX-COM compiles a model into a .dxnn file. DX-APP builds the application that loads that file and runs inference. Most projects use both: compile first, then build the app.

Which Sixfab products does it work with?

The Sixfab AI HAT+ and Edge AI Expansion Board on a Raspberry Pi 5, and the ALPON X5 AI. Use Raspberry Pi OS Trixie (Bookworm also works), and install the runtime with the quickstart for your device first.

Should I choose Python or C++?

Start with Python sync. It's the easiest to read and debug. Move to the async variants when you want pipelined processing, and to C++ when you need a native app.

Do I need an NPU to validate the app?

Not for levels 1 to 3 (static checks, config checks, and smoke tests). Levels 4 and 5, which run real inference and measure FPS, need a DX-M1.

What do the [DX-AGENT-DEV: START] and [DX-AGENT-DEV: DONE ...] lines mean?

They're fixed markers the agent prints at the start and end of each task, mainly for automated testing. The DONE line includes your output folder, for example [DX-AGENT-DEV: DONE (output-dir: dx-agent-dev/<session_id>)]. The agent only prints DONE after it has produced code, scripts, configs, and validation results, not after planning alone.

Why does the agent ask questions I already answered in my prompt?

The three questions (variant, task, model) are mandatory. The agent confirms them every time, even when your prompt already contains the answers.



Did this page help you?