Using agentic AI to create inference snaps¶
In this tutorial, you’ll package an inference snap with Workshop and the inference-snaps-sdk.
Starting from a repository created from the inference snap template, you’ll prepare two input files, run the packaging pipeline through an LLM agent, then install and start the snap on your machine.
You’ll do this with the help of an LLM of your choice.
By the end of this tutorial you’ll have a working qwen3-5 snap that starts and responds to a prompt.
Experimental workflow
This packaging workflow is experimental. The steps, prompts, and generated outputs may change, and you may need to make manual adjustments before opening a pull request.
Before you start¶
This tutorial builds on snap packaging and inference snap concepts. Work through these tutorials first:
To follow this tutorial, you need:
A Linux machine where you can install and run snaps.
Workshop installed on your machine. If you are new to Workshop, see Install Workshop.
Network access to download the Qwen 3.5 model files from Hugging Face.
For more detail on the tools used along the way, see OpenCode integration, the Network ports registry, and Troubleshooting.
1. Open your snap project¶
Go to the Inference Snap Template repository and click on Use this template. This will create a new inference snap repository under your GitHub account containing the minimal files to follow this tutorial. Clone your inference snap repository and move into it:
git clone <your-inference-snap-repo-url>
cd <your-inference-snap-repo>
List the directory contents. You should see three files:
user@host:~$ lsMakefile README.md workshop.yaml
These files are the inputs for the packaging pipeline.
2. Prepare the inputs¶
The pipeline needs two things from you: the model files to download, and the snap metadata.
You provide these by editing the Makefile and the README.md.
Makefile¶
First, open the Makefile and replace its contents with the following, which downloads a single Qwen 3.5 model file:
SHELL := /bin/bash
.PHONY: download-models setup-hf-cli
all: download-models
download-models: download-model
setup-hf-cli:
sudo apt-get install -y python3-venv
python3 -m venv .venv
. .venv/bin/activate && pip install --upgrade pip && pip install -U huggingface_hub
download-model: setup-hf-cli
. .venv/bin/activate && hf download hf://unsloth/Qwen3.5-4B-GGUF/Qwen3.5-4B-UD-Q4_K_XL.gguf --local-dir components/model-q4-k-xl-gguf
This sets up the Hugging Face CLI in a local virtual environment and downloads the model file into the components/ directory, where the pipeline expects the files that become part of the snap.
README¶
Next, open README.md and fill in the metadata block at the top of the file, between the <!-- and --> comment tags, with these values:
snap-name: qwen3-5
snap-friendly-name: Qwen 3.5
model-card: https://qwen.ai/blog?id=qwen3.5
http-port: 8352
webui-http-port: 8353
engines: cpu
Notice a few things about this block:
snap-nameuses only lowercase letters, digits, and hyphens. It becomes the CLI command users run after installation.The ports
8352and8353must not clash with entries in the Network ports registry.engines: cpukeeps this first build simple by targeting a single hardware optimization.
Your two inputs are now ready: the Makefile downloads the model, and the README.md metadata describes the snap.
3. Package the inference snap¶
With the inputs ready, you can launch Workshop and run the packaging pipeline.
Launch Workshop¶
Workshop is a confined environment that includes only the necessary dependencies for a specific purpose.
These dependencies are called SDKs.
The workshop environment is described by a workshop.yaml file.
Start the Workshop environment now by running this command from the project root directory.
workshop launch
Then open a shell inside it:
workshop shell
Confirm that you are inside the Workshop shell:
workshop@dev:/project$ whoamiworkshop
If the output is not workshop, stop here. Exit and check that Workshop launched correctly before you continue. You can refer to the Workshop documentation for help.
Start OpenCode¶
The workshop includes the inference-snaps-sdk, which ships with OpenCode, a terminal UI for running LLM agents. For more information, see the OpenCode documentation.
Inside the Workshop shell, start OpenCode:
opencode --auto
The OpenCode TUI opens with the skills and agents installed by inference-snaps-sdk. The --auto flag approves permission prompts automatically, which is safe here because the Workshop environment is sandboxed.
OpenCode can be configured to use a local LLM or a remote API. If you want to use a local model, see OpenCode configuration. You can also use a remote model by providing an API key for a service like Claude or OpenAI. In order to do that you can send this command in the OpenCode TUI:
/connect
You will be prompted to select a provider and enter your API key or redirected to a web page to log in. After you connect, you can use the remote model for the packaging pipeline.
By default, OpenCode uses the Big Pickle model from OpenCode Zen. You are free to use any model you prefer.
Run the packaging pipeline¶
In the OpenCode TUI, enter this prompt:
start snap packaging pipeline
The pipeline validates your inputs, summarizes what it found, and asks you to confirm before it starts. Read the summary and check that it matches:
the snap name
qwen3-5the Qwen 3.5 model file from the
Makefilethe
cpuengine
Confirm to continue. The pipeline generates the packaging files, builds the snap, and prepares a pull request description.
When the run finishes, you’ll have:
one or more build artifacts, such as
.snapand.compfiles, in the project directorya generated PR description ready for review
If the pipeline stops on a validation error, fix the reported problem and ask the agent to continue.
4. Test your snap¶
Exit from the OpenCode TUI by typing /exit and pressing ENTER or with CTRL+c. Then exit the Workshop shell to return to your machine:
workshop@dev:/project$ exitexit
user@host:~$ whoamiuser
From the project directory, install the generated artifacts:
sudo snap install *.snap *.comp --dangerous
Now start the snap and chat with the model:
qwen3-5 chat
The command connects to the model server and waits for your prompt.
Type a message and press ENTER.
You should see a response arriving for the message you typed.
Next, check the configured ports:
user@host:~$ qwen3-5 gethttp.host: 127.0.0.1
http.port: 8352
...
webui.http.host: 127.0.0.1
webui.http.port: 8353
Notice that the ports match the 8352 and 8353 values you set in README.md. Open the Web UI in your browser at http://127.0.0.1:8353.
You have now confirmed that the qwen3-5 snap installs, starts, and exposes the ports you configured.
5. Open a PR for your newly packaged inference snap¶
The packaging run generated a PR description together with the build outputs.
Before you open a pull request, confirm that the packaging matches what you intended:
user@host:~$ qwen3-5 list-enginescpu
user@host:~$ qwen3-5 list-modelsmodel-q4-k-xl-gguf
The cpu engine and the Qwen 3.5 model match the values you set in README.md and the file downloaded by the Makefile.
With the build artifacts produced and the snap running locally, open a pull request to your inference snap repository using the generated PR description as the starting point.
You’ve now packaged an inference snap end to end with Workshop: you prepared the inputs, ran the packaging pipeline, installed the snap, and confirmed it runs.