01 · Foundations
Understand the current API model
OpenGame uses JSON application routes for account data and generation orchestration, plus direct responses for playable previews and artifact downloads.
Session authentication
The web routes documented here use the signed-in OpenGame browser session unless an endpoint explicitly states another scheme.
JSON envelopes
Successful JSON routes generally return code, message, and data. Errors include an HTTP status and a stable error code where available.
Asynchronous runs
Generation and Studio creation return HTTP 202 because work may continue after the initial request is accepted.
02 · Generator
Create and inspect a generator run
The lightweight generator accepts a focused prompt, queues a homepage generation run, and exposes the run by ID.
/api/generator/runsCreate a signed-in generator run. Prompt is required and limited to 4,000 characters; provider and paid fallback are optional. Returns HTTP 202 when accepted.
/api/generator/runs/:idRead one generator run owned by the current user. Returns 404 when the ID is missing or belongs to another account.
/api/creditsRead total, paid Studio, and Free Generator balances together with recent credit history for the signed-in account.
const response = await fetch("/api/generator/runs", {
method: "POST",
credentials: "include",
headers: { "content-type": "application/json" },
body: JSON.stringify({
prompt: "Build a short neon arcade game with fast retries.",
usePaidFallback: false
})
});
const payload = await response.json();
const run = payload.data;03 · Studio
Work with Studio runs
Studio exposes persistent run history and a richer creation payload for output mode, thread continuity, model selection, and asset behavior.
/api/studio/runs?limit=10List the current user’s most recent Studio runs. Limit is clamped between 1 and 20.
/api/studio/runsCreate and begin processing a Studio run. Supports quick HTML or game bundle modes plus optional thread, parent run, provider, model, intent, artifact context, and asset mode fields.
/api/studio/runs/:idRead a single Studio run and its serialized artifact state for the signed-in owner.
POST /api/studio/runs
Content-Type: application/json
{
"prompt": "Build a one-level browser platformer.",
"mode": "game_bundle",
"intent": "auto",
"assetMode": "auto"
}Quick HTML
Use quick_html for a focused, single-file playable result when speed and portability matter most.
Game bundle
Use game_bundle for advanced multi-file browser games with a manifest, assets, and a dedicated entry document.
04 · Delivery
Preview, download, and publish artifacts
Completed runs can expose an isolated preview, a downloadable artifact, and an optional public game publication.
/api/game-artifacts/:id/previewReturn the playable artifact preview. Access is resolved from the current session or a valid preview token.
/api/game-artifacts/:id/downloadDownload an artifact owned by the signed-in user. The response is the artifact file or bundle rather than a JSON envelope.
/api/game-publications/:artifactIdRead the current public publication record for an artifact owned by the signed-in user.
/api/game-publications/:artifactIdPublish an eligible HTML artifact with a title, description, optional controls, and optional structured SEO content.
/api/game-publications/:artifactIdUnpublish the signed-in owner’s public game while keeping the underlying generated artifact.
POST /api/game-publications/:artifactId
Content-Type: application/json
{
"title": "Neon Dash",
"description": "A fast one-button arcade challenge.",
"controls": ["Space — dash", "R — restart"]
}05 · Reliability
Handle expected failure states
Use the HTTP status for control flow and the response code for a stable application-level reason whenever it is present.
Sign in again before retrying the request.
The selected generator or Studio credit balance is insufficient.
The run or artifact does not exist for the current owner.
A public game URL could not be allocated.
The submitted payload failed validation.
The generation queue is temporarily unavailable.