Edge Impulse API on-device build & download

Hi everyone,

I’ve created a model and I’m trying to use the EI API to automate the process of deployment a bit.
More specifically

  • Use the API to retrain the model after I add some new data (using Ingestion). This works although I have to poll the job status to find out when it’s finished and get the logs on end.

  • Use the https://docs.edgeimpulse.com/reference#buildondevicemodeljob to build the on-device model. This also seems to work. Same way as before, poll for job end and get logs.

  • What I’m having trouble with is then download part, using https://studio.edgeimpulse.com/v1/api/projectId/deployment/download. I do get a “zip” file with the content No deployment exists, did you build yet?

I can’t find any help on how to use these 2 calls together to successfully build & download an arduino library zip locally so I can automate the build process in PlatformIO.

Also, on the documentation side, it’s not really clear what the options are for building & downloading, e.g type, modelType.

Any help would be greatly appreciated!


Hi @SpirosMakris you need to pass in ?type=arduino to the download call to get the Arduino lib.

1 Like

Hi @janjongboom,
thanks for the reply!

I was already using the type query param and it had the behavior described above, but
I tested again after manually building & downloading (from Studio) and this time it worked.

Don’t know what I did wrong initially…

For reference, my settings for the build call are:

  const build_url = `https://studio.edgeimpulse.com/v1/api/${project_id}/jobs/build-ondevice-model?type=arduino`;
  const build_options = {
    method: 'POST',
    headers: {
      Accept: 'application/json',
      'Content-Type': 'application/json',
      'x-api-key': api_key,
    body: JSON.stringify({ engine: 'tflite-eon', modelType: 'int8' })

and for the download call:

  const dl_url = `https://studio.edgeimpulse.com/v1/api/${prj_id}/deployment/download?type=arduino`;

  const dl_options = {
    method: 'GET',
    headers: {Accept: 'application/zip', 'x-api-key': api_key},


1 Like

Yeah that should be OK. Here’s an example as well from the mobile client: https://github.com/edgeimpulse/mobile-client/blob/332114b8fdaab9b4b3e137baa190d5b3b7e8f64e/client/classification-loader.ts#L186

1 Like

Hi @janjongboom,

Thanks for the confirmation and the example code!