Method Signature
Parameters
Object containing the prompt and/or image to update. At least one of
prompt or image must be provided.Return Value
A promise that resolves when the update is complete, or rejects if:
- The connection is not active
- Input validation fails
- The server rejects the update
- The operation times out (30 seconds)
Error Handling
The method throws an error if:- Connection is not in
"connected"or"generating"state - Neither
promptnorimageis provided promptis an empty string- Image format is invalid or cannot be fetched
- Server rejects the update
- Operation times out after 30 seconds
Usage Examples
Update Both Prompt and Image
Update Only Prompt
Update Only Image
Clear Reference Image
Image from File Input
Image from URL
Image from Data URL
Sequential Updates
Dynamic State Management
Implementation Details
Timeout
The method has a built-in timeout of 30 seconds for the update operation. This is longer thansetPrompt() because image uploads may take additional time.
Image Processing
When an image is provided:- If it’s a URL (HTTP/HTTPS), it’s fetched automatically
- If it’s a data URL, the base64 part is extracted
- If it’s a Blob/File, it’s converted to base64
- The base64 image is sent to the server via WebSocket
Validation
The method validates:- At least one of
promptorimagemust be provided - If
promptis provided, it must be a non-empty string - If
imageis provided, it must be a valid format - Connection must be active (
"connected"or"generating"state)
Comparison with Other Methods
| Method | Updates Prompt | Updates Image | Use Case |
|---|---|---|---|
set() | ✓ | ✓ | Update prompt and/or image together |
setPrompt() | ✓ | ✗ | Update only prompt with faster acknowledgment |
setImage() | ✗ | ✓ | Update only image with additional options |
See Also
- setPrompt() - Update only the prompt
- connect() - Initial connection with state
- Events - Monitor state changes