Skip to main content
Edit an existing screen with natural language instructions. The API supports multiple strategies for applying changes efficiently.

Endpoint

POST /api/edit-screen

Request Body

prompt
string
required
Natural language description of the changes to make.
currentHtml
string
required
The current HTML content of the screen to edit.
screenId
string
Identifier for the screen being edited.
sandboxId
string
Sandbox ID where the screen file should be updated.
pageSlug
string
Page slug of the file to update in the sandbox.
model
string
default:"google/gemini-2.0-flash"
AI model to use. Options:
  • google/gemini-2.0-flash
  • anthropic/claude-sonnet-4
  • openai/gpt-4o
  • groq/llama-3.3-70b

Example Request

curl -X POST http://app.seemodo.ai/api/edit-screen \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Change the primary button color to blue and add a subtitle under the heading",
    "currentHtml": "<div class=\"p-4\"><h1 class=\"text-2xl\">Welcome</h1><button class=\"bg-green-500 px-4 py-2\">Get Started</button></div>",
    "sandboxId": "sandbox-abc123",
    "pageSlug": "welcome"
  }'

Response

success
boolean
Whether the edit was successful.
html
string
The modified HTML content.
message
string
Description of changes applied.
changes
array
List of changes made.
sandboxUrl
string
URL to view the updated page (if sandbox was provided).
shouldReload
boolean
Whether the preview should be refreshed.
useSeemodAI
boolean
Whether Seemodo AI was used for the edit.

Success Response

{
  "success": true,
  "html": "<div class=\"p-4\"><h1 class=\"text-2xl\">Welcome</h1><p class=\"text-gray-600 mt-1\">Start your journey with us</p><button class=\"bg-blue-500 px-4 py-2\">Get Started</button></div>",
  "message": "Applied changes: Change the primary button color to blue and add a subtitle",
  "changes": ["Changed button color to blue", "Added subtitle text"],
  "sandboxUrl": "https://sandbox-abc123.modal.run/welcome",
  "shouldReload": true,
  "useSeemodAI": true
}

Edit Strategies

The API uses multiple strategies in order of preference:

Strategy 1: Seemodo AI (Preferred)

When a Modal sandbox is active, uses Seemodo AI to directly edit files:
  • Reads the current file
  • Applies minimal changes
  • Writes back to sandbox
  • HMR updates preview automatically

Strategy 2: Full Regeneration

Fallback when Seemodo AI isn’t available:
  1. AI generates complete modified HTML
  2. Preserves structure while applying changes
  3. Result is written to sandbox

Common Edit Examples

{
  "prompt": "Make the card have a subtle shadow and rounded corners",
  "currentHtml": "<div class=\"border p-4\">Card content</div>"
}

Integration Example

async function editScreen(prompt) {
  // Get current screen content
  const currentHtml = document.getElementById('screen-container').innerHTML;
  
  const response = await fetch('/api/edit-screen', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      prompt,
      currentHtml,
      sandboxId: activeSandbox.id,
      pageSlug: currentPage.slug,
      model: 'anthropic/claude-sonnet-4'
    })
  });
  
  const result = await response.json();
  
  if (result.success && result.shouldReload) {
    // Refresh the preview iframe
    previewFrame.src = result.sandboxUrl;
  }
  
  return result;
}

Best Practices

  1. Be specific - “Change button to blue” is better than “update colors”
  2. One change at a time - For predictable results, make focused edits
  3. Reference elements - “The submit button” is clearer than “the button”
  4. Use Tailwind terms - “Add shadow-lg” is precise

Notes

  • HMR automatically updates the preview when files change
  • The endpoint preserves existing functionality when making visual changes
  • Seemodo AI provides the most reliable edits for complex changes