9e6b4dc7fa
- Add 1536x864, 864x1536, 2048x1152, 1152x2048, 2560x1440 to the size dropdown. 2560x1440 is the OpenAI cookbook's recommended upper widescreen reliability boundary - Note that sizes above 2560x1440 are experimental and the max-edge rule is strictly <3840 (3840x2160 is out, use 3824x2144 instead) - 1920x1080 is invalid because 1080 isn't a multiple of 16 — captured in AGENTS.md alongside the full constraint set so future agents stop proposing it
249 lines
5.6 KiB
HTML
249 lines
5.6 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>AI Image Playground</title>
|
|
<style>
|
|
:root {
|
|
color-scheme: light dark;
|
|
--bg: #0b0d10;
|
|
--panel: #14171c;
|
|
--border: #262a31;
|
|
--text: #e6e6e6;
|
|
--muted: #9aa3af;
|
|
--accent: #6366f1;
|
|
--accent-hover: #4f46e5;
|
|
--danger: #ef4444;
|
|
}
|
|
* {
|
|
box-sizing: border-box;
|
|
}
|
|
body {
|
|
margin: 0;
|
|
font-family:
|
|
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
background: var(--bg);
|
|
color: var(--text);
|
|
min-height: 100vh;
|
|
}
|
|
.container {
|
|
max-width: 960px;
|
|
margin: 0 auto;
|
|
padding: 32px 20px 64px;
|
|
}
|
|
h1 {
|
|
margin: 0 0 8px;
|
|
font-size: 24px;
|
|
}
|
|
p.sub {
|
|
margin: 0 0 24px;
|
|
color: var(--muted);
|
|
font-size: 14px;
|
|
}
|
|
.panel {
|
|
background: var(--panel);
|
|
border: 1px solid var(--border);
|
|
border-radius: 12px;
|
|
padding: 20px;
|
|
}
|
|
.grid {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 12px;
|
|
}
|
|
label {
|
|
display: block;
|
|
font-size: 12px;
|
|
color: var(--muted);
|
|
margin-bottom: 6px;
|
|
}
|
|
input,
|
|
textarea,
|
|
select {
|
|
width: 100%;
|
|
background: #0b0d10;
|
|
color: var(--text);
|
|
border: 1px solid var(--border);
|
|
border-radius: 8px;
|
|
padding: 10px 12px;
|
|
font-size: 14px;
|
|
font-family: inherit;
|
|
}
|
|
input:focus,
|
|
textarea:focus,
|
|
select:focus {
|
|
outline: 2px solid var(--accent);
|
|
outline-offset: -1px;
|
|
}
|
|
textarea {
|
|
min-height: 96px;
|
|
resize: vertical;
|
|
}
|
|
.row {
|
|
margin-bottom: 12px;
|
|
}
|
|
.actions {
|
|
display: flex;
|
|
gap: 12px;
|
|
align-items: center;
|
|
margin-top: 16px;
|
|
}
|
|
button {
|
|
background: var(--accent);
|
|
color: white;
|
|
border: 0;
|
|
padding: 10px 16px;
|
|
border-radius: 8px;
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
}
|
|
button:hover {
|
|
background: var(--accent-hover);
|
|
}
|
|
button:disabled {
|
|
opacity: 0.6;
|
|
cursor: not-allowed;
|
|
}
|
|
.status {
|
|
font-size: 13px;
|
|
color: var(--muted);
|
|
}
|
|
.status.error {
|
|
color: var(--danger);
|
|
}
|
|
.ref-preview {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 8px;
|
|
margin-top: 8px;
|
|
}
|
|
.ref-preview:empty {
|
|
display: none;
|
|
}
|
|
.ref-preview .thumb {
|
|
position: relative;
|
|
width: 64px;
|
|
height: 64px;
|
|
border-radius: 8px;
|
|
overflow: hidden;
|
|
border: 1px solid var(--border);
|
|
}
|
|
.ref-preview .thumb img {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
display: block;
|
|
}
|
|
.ref-preview .thumb .remove {
|
|
position: absolute;
|
|
top: 2px;
|
|
right: 2px;
|
|
width: 18px;
|
|
height: 18px;
|
|
padding: 0;
|
|
border: 0;
|
|
border-radius: 50%;
|
|
background: rgba(0, 0, 0, 0.7);
|
|
color: white;
|
|
font-size: 12px;
|
|
line-height: 18px;
|
|
cursor: pointer;
|
|
font-weight: bold;
|
|
}
|
|
.hint {
|
|
display: block;
|
|
margin-top: 6px;
|
|
color: var(--muted);
|
|
font-size: 12px;
|
|
}
|
|
.hint code {
|
|
background: rgba(255, 255, 255, 0.06);
|
|
padding: 1px 4px;
|
|
border-radius: 4px;
|
|
}
|
|
input[type="file"] {
|
|
padding: 8px;
|
|
}
|
|
.result {
|
|
margin-top: 24px;
|
|
display: grid;
|
|
gap: 16px;
|
|
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
|
}
|
|
.result img {
|
|
width: 100%;
|
|
border-radius: 12px;
|
|
border: 1px solid var(--border);
|
|
display: block;
|
|
}
|
|
details {
|
|
margin-top: 12px;
|
|
font-size: 13px;
|
|
color: var(--muted);
|
|
}
|
|
summary {
|
|
cursor: pointer;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>AI Image Playground</h1>
|
|
<p class="sub">
|
|
Generate images via any OpenAI-compatible endpoint using the Vercel AI SDK.
|
|
</p>
|
|
|
|
<div class="panel">
|
|
<div class="row">
|
|
<label for="size">Size</label>
|
|
<select id="size">
|
|
<option value="1024x1024">1024x1024 (1:1 square)</option>
|
|
<option value="1536x1024">1536x1024 (3:2 landscape)</option>
|
|
<option value="1024x1536">1024x1536 (2:3 portrait)</option>
|
|
<option value="1536x864">1536x864 (16:9 landscape)</option>
|
|
<option value="864x1536">864x1536 (9:16 portrait)</option>
|
|
<option value="2048x1152">2048x1152 (16:9 2K landscape)</option>
|
|
<option value="1152x2048">1152x2048 (9:16 2K portrait)</option>
|
|
<option value="2560x1440">2560x1440 (16:9 QHD — experimental boundary)</option>
|
|
</select>
|
|
<small class="hint">
|
|
Sizes above 2560x1440 are experimental for <code>gpt-image-2</code>.
|
|
Both edges must be a multiple of 16; max edge < 3840.
|
|
</small>
|
|
</div>
|
|
<div class="row">
|
|
<label for="prompt">Prompt</label>
|
|
<textarea
|
|
id="prompt"
|
|
placeholder="A futuristic cityscape at sunset, cinematic lighting"
|
|
></textarea>
|
|
</div>
|
|
<div class="row">
|
|
<label for="refImages">Reference images (optional)</label>
|
|
<input id="refImages" type="file" accept="image/*" multiple />
|
|
<div id="refPreview" class="ref-preview"></div>
|
|
<small class="hint">
|
|
Provide one or more references to keep style consistent. When set,
|
|
the request is sent to <code>/v1/images/edits</code> (gpt-image series only).
|
|
</small>
|
|
</div>
|
|
<div class="actions">
|
|
<button id="generate">Generate</button>
|
|
<span id="status" class="status"></span>
|
|
</div>
|
|
<details>
|
|
<summary>Size and prompt are saved to your browser's localStorage</summary>
|
|
Base URL, API key and model live in the server's <code>.env</code> —
|
|
they are never sent from the browser.
|
|
</details>
|
|
</div>
|
|
|
|
<div id="result" class="result"></div>
|
|
</div>
|
|
|
|
<script type="module" src="./client.ts"></script>
|
|
</body>
|
|
</html>
|