The Purpose of Multi-Model Prompt Sandboxing§

Prompt engineering requires empirical comparison. Testing a prompt on a single model often hides subtle formatting quirks, latency differences, or cost inefficiencies. A Multi-Model Prompt Sandbox enables developers to submit a test prompt once and stream live side-by-side responses from OpenAI, Anthropic, DeepSeek, and Google models concurrently.

[Loading prompt card for DeepSeek Chat...]

---

System Architecture: Concurrent SSE Streaming§

                      ┌─── Stream 1 ───► [ OpenAI GPT-4o ]
                      ├─── Stream 2 ───► [ Anthropic Claude ]
 [ Client Web Panel ] ┤
                      ├─── Stream 3 ───► [ DeepSeek V3 ]
                      └─── Stream 4 ───► [ Google Gemini ]

Client-Side Connection Orchestration§

export async function executeParallelSandboxPrompt(
  prompt: string,
  models: string[],
  onChunk: (model: string, chunk: string) => void
) {
  const fetchPromises = models.map(async (model) => {
    const response = await fetch("/api/sandbox/run", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ prompt, model }),
    });

    const reader = response.body?.getReader();
    const decoder = new TextDecoder();
    if (!reader) return;

    while (true) {
      const { done, value } = await reader.read();
      if (done) break;
      const text = decoder.decode(value);
      onChunk(model, text);
    }
  });

  await Promise.all(fetchPromises);
}