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

Request

  • Base URL
    https://api.qomplement.com (the document declares no server; this is the origin it was published from)
  • URL
    https://api.qomplement.com/api/document/edit-visual
  • Auth
    none declared

Request body multipart/form-data

filestring binary nullable

Document image to edit (JPEG, PNG, WebP, or PDF)

document_idstring nullable

Document ID to fetch from S3 (alternative to file upload)

batch_idstring nullable

Batch ID for document (used with document_id)

page_numberinteger

Page number to edit (for multi-page documents)

changesstring required

JSON array of field changes: [{fieldName, oldValue, newValue}]

user_idstring required

User ID for file organization

original_document_idstring

Original document ID for tracking

Response

Successful Response

unknown required

Changes

No recorded changes to this operation across all 9 revisions of this API.