v1

latestOpenAPI 3.1.02026-08-04552282508.9 KB
Gemini Document Editor

Edit Document Visual

Visually edit a document using Gemini 2.5 Flash Image API

This endpoint:

  1. Receives a document image + list of field changes
  2. Builds an intelligent prompt with strict formatting preservation
  3. Calls Gemini 2.5 Flash Image to generate edited version
  4. Saves edited document to S3 with 'edited' metadata
  5. Returns document metadata with S3 URL for download

Example request:

POST /api/document/edit-visual
Content-Type: multipart/form-data

file: [document.jpg]
changes: [
    {"fieldName": "Name", "oldValue": "Andres", "newValue": "Fernando"},
    {"fieldName": "Total", "oldValue": "100.00", "newValue": "150.00"}
]
user_id: "user_123"
original_document_id: "doc_456" (optional)

Args: file: Document image file to edit changes: JSON string of field changes [{fieldName, oldValue, newValue}] user_id: User ID for S3 file organization original_document_id: Optional original document ID for tracking s3_storage: S3Storage instance (injected)

Returns: JSON with edited document metadata: - document_id: Unique ID for edited document - s3_url: Download URL for edited document - s3_key: S3 storage key - is_edited: True (tagged as edited) - changes_applied: Number of field changes - changes: List of changes applied

Raises: HTTPException: If Gemini API call fails or invalid input

post/api/document/edit-visual

Response

Successful Response

{"stackTrail":"paths:/api/document/edit-visual:post:responses:200:content:application/json:schema","oasType":"schema","type":"unknown"}