Get url for image through API


when I call the API to start a job, and then get the result from an ImageView, the image is in the response as a base64 encoded string. Which is nice, but unfortuantely on the client-side I have no way of actually converting that to an image. Is it possible to get the url to a generated image, just like for the 3D model?


To give this a nudge: can I save a file or something, and retrieve that with the API instead?

Hi Mark,

I’m having a bit of a hard time figuring out what exactly you want to accomplish. As far as I understand you have an app somewhere which you’re running jobs on from somewhere else through the API. Now you want the image produced in an ImageView to be available outside the app as well?

Sure, let me give you more context.

I’m using chatGPT (with a customer GPT action) to talk to the Viktor API. ChatGPT translates the use request in natural language into a parametrized request, that I send to Viktor, which then creates 2D image. The image is in the body of the API response as a base64 string (if I’m correct). Normally you’d be able to convert that into the image to display on the screen. ChatGPT however can’t do this - hence I was wondering if there was an alternative way to share the image, e.g. as an URL I can download it from, like what happens when I create a 3D model (geometryview).

I hope this clarifies my struggle :slight_smile:

Hmm, I’ve asked around and we couldn’t really find an in-product workaround for this right now. The simplest route is probably to find another way to translate the base-64 data back to an image and the the download url from there (something like this)

Thanks again for the response. Looking at your API I had another thought, but perhaps I misinterpret how it works. The Python API has a Storage module, where files can be stored. Wouild storing a file using that be an option, and then afterwards retrieving it through the Download File by Id | VIKTOR Documentation endpoint? Or are those two (Storage module vs File API) different things?

Hi Mark,

Nice find, I was looking into that as well, but in that case you’d have to get the current session id to actually get the correct files. The API is built so you can interact with an application from the outside, not necessarily from within the app itself.
Feel free to try and experiment (we always encourage that mentality :wink:) and let us know about your progress. Though beware that it might just be simpler in the end to process the base-64 data somehow.

1 Like