Skip to main content

API reference

OpenGame API reference

Reference the first-party OpenGame web contracts for generation runs, Studio projects, credits, previews, downloads, and game publication. The routes below reflect the current application behavior rather than a speculative SDK.

Live surface

Session-authenticated contracts

  1. 01Create generationPOST /generator/runs
  2. 02Inspect StudioGET /studio/runs
  3. 03Preview artifactGET /preview
  4. 04Publish gamePOST /publications

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.

POST/api/generator/runs

Create 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.

GET/api/generator/runs/:id

Read one generator run owned by the current user. Returns 404 when the ID is missing or belongs to another account.

GET/api/credits

Read total, paid Studio, and Free Generator balances together with recent credit history for the signed-in account.

Same-origin browser exampleOpenGame
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.

GET/api/studio/runs?limit=10

List the current user’s most recent Studio runs. Limit is clamped between 1 and 20.

POST/api/studio/runs

Create 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.

GET/api/studio/runs/:id

Read a single Studio run and its serialized artifact state for the signed-in owner.

Minimal Studio requestOpenGame
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.

GET/api/game-artifacts/:id/preview

Return the playable artifact preview. Access is resolved from the current session or a valid preview token.

GET/api/game-artifacts/:id/download

Download an artifact owned by the signed-in user. The response is the artifact file or bundle rather than a JSON envelope.

GET/api/game-publications/:artifactId

Read the current public publication record for an artifact owned by the signed-in user.

POST/api/game-publications/:artifactId

Publish an eligible HTML artifact with a title, description, optional controls, and optional structured SEO content.

DELETE/api/game-publications/:artifactId

Unpublish the signed-in owner’s public game while keeping the underlying generated artifact.

Minimal publication requestOpenGame
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.

401

Sign in again before retrying the request.

402

The selected generator or Studio credit balance is insufficient.

404

The run or artifact does not exist for the current owner.

409

A public game URL could not be allocated.

422

The submitted payload failed validation.

503

The generation queue is temporarily unavailable.