KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Reusing image context with the vision helper
PRODUCT: 4D | VERSION: 21 | PLATFORM: Mac & Win
Published On: April 6, 2026
The vision helper in 4D AIKit allows multiple .prompt() calls to be executed on the same image within a single session. Once an image is initialized with vision.create(), it can be referenced for several queries without creating a new helper instance.

var $helper := $client.chat.vision.create($imageURL)

var $desc := $helper.prompt("Describe this image.")
var $color := $helper.prompt("What is the dominant color?")
var $labels := $helper.prompt("Identify objects present in the image")


This guarantees :
  • Persistent context: The same helper instance maintains the image context, so multiple prompts can operate on it sequentially.

  • Flexible queries: Each prompt can target a different aspect of the image, such as color, defects, or classification.

  • Per-call parameters: Optional parameters such as model selection or token limits can be customized for each prompt without affecting the session.

This approach allows structured, multi-step image analysis in a single session while keeping the helper instance consistent. By maintaining the image context, it avoids the need to create new helper instances for each question, simplifying session management and making the workflow more organized.