Skip to main content
After this guide, a device uploads a file with its own credential and returns a public URL the agent can show or store. Use this for screenshots, photos, and logs; for values that fit in a command result, return them directly, since a command response is capped at 1 MB and a file on the CDN is not part of the conversation until you share its URL. Verified against @lua-ai-global/device-client 1.1.0, lua-device-client 1.3.0, and lua-cli 3.45.0. Before you begin
  • A device credential that grants assets.upload; the CDN refuses uploads from a credential without it. Issue one with lua devices credential --device-name <name> --operations commands,assets.upload.
  • The Node or Python client. The MicroPython client has no CDN support.
1

Upload from a command handler

cdn.upload sends the bytes as a multipart upload and resolves with the file’s ID and URL. One file per call, at most 100 MB.
device.ts
The result’s url is https://cdn.heylua.ai/<fileId>, and mediaType and extension report what the CDN detected. cdn.upload is a plain HTTPS request carrying the credential, independent of the device connection, so it works while the socket is down or before connect(). url never expires and is fetched without a credential, so anyone holding it can open the file; the client has no delete call, and files are removed only when the owning account is erased.
2

Hand the URL to the agent

Returning the URL from a command puts it in the tool result, so the model can share it in the conversation. For a device-initiated event, put the URL in a trigger payload and store or forward it in the handler.
device.ts
src/devices/ShelfPhotoTaken.ts
3

Verify

Call the command by hand and open the returned URL.
The reply contains url; fetching it returns the file with the detected media type.

Options you may need

Download or rebuild a URL

cdn.download(fileId) fetches the bytes back (Buffer in Node, bytes in Python) and cdn.getUrl(fileId) (get_url in Python) rebuilds the URL from an ID you stored.

Files from the agent side

Code running on the platform uploads through the CDN runtime object instead of a device credential.

If it isn’t working

The credential doesn’t grant assets.upload (the CDN answers Device credentials require a designated device endpoint), or it was revoked. Issue a new credential with the operation; operations can’t be added later.
The cap is 100 MB per file. Compress or split the file.

Next steps

Node device client

The CDN class and CdnUploadResult.

Handle device triggers

Handlers for device-initiated events.

Laptop controller

Screenshots uploaded from a laptop.