Reuse an uploaded image in the DeepSeek API
Reference a saved image by its file identifier when asking a visual question.
In this article
Upload the practice image
For developers with API access, the upload reference specifies a multipart/form-data POST to /files. Send the image in file and set purpose to user_data. Accepted formats are JPEG, PNG, GIF and WebP, with a maximum file size of 64 MiB. Keep the returned id. Expiration is optional: supply both expires_after[anchor]=created_at and expires_after[seconds], from 3600 to 2592000. Omitting both keeps the file permanently.
Check the saved file
The retrieval endpoint uses GET /files/:file_id and returns information about that file. Our suggested check is to compare filename and bytes with the image you intended to upload, and retain its identifier for the next request. The response also includes created_at and purpose; expires_at appears only if expiration was set. This checks file metadata, not whether a model has correctly understood the picture.
Ask a visual question
Follow the vision example: configure the OpenAI client with your DeepSeek API key and https://api.deepseek.com, then use deepseek-flash. A user message contains a text block and a file block carrying file_id. Our illustrative task: use your own blue-mug picture, ask what object is visible, and compare response.choices[0].message.content with the image. This is a proposed exercise, not a test result. Reuse that identifier for another image question.
Remove the file when finished
If you want to remove the uploaded file, the deletion reference specifies DELETE /files/:file_id. Our suggested completion check is to inspect the returned id and deleted boolean together. The identifier tells you which file the response concerns; deleted reports whether deletion succeeded. Do not treat a response about another identifier as confirmation for this image.
Original CurioFuse editorial. A guide to explore and evaluate AI, without an implied product test.
