AI asset generation for PlayDrop games
Generate images, music, sound, speech, video and 3D for a game in PlayDrop, from the browser with player confirmation or from a server paid by the creator.
PlayDrop can generate images, music, sound effects, speech, video and 3D models. Use it while making a game, or inside a game so players get generated content.
While making the game
Signed-in creators generate assets from Create on the PlayDrop website (image, music, sound, speech, video and 3D) or ask PlayDrop Cloud while building a game. Each generation costs credits, shown before it starts, and the result becomes an asset you own. Use it like any other asset: download it into your package or reference it in uses (game assets).
Inside a game: from the browser
sdk.ai.<kind>.createTask(request) asks PlayDrop to generate media for the current player. PlayDrop shows the player a confirmation with the credit cost, the player pays, and the result is private to them.
try {
const task = await sdk.ai.image.createTask({ input: "A friendly robot pet, flat colors", aspectRatio: "1:1" });
const done = await waitForTask(task.id);
const blob = await sdk.ai.tasks.downloadFile(done.id);
showPet(URL.createObjectURL(blob));
} catch (error) {
if (error.message === "ai_generation_cancelled") return;
throw error;
}
async function waitForTask(id) {
for (;;) {
const task = await sdk.ai.tasks.get(id);
if (task.status === "DONE") return task;
if (["FAILED", "CANCELLED", "EXPIRED"].includes(task.status)) throw new Error(task.status);
await new Promise((resolve) => setTimeout(resolve, 2000));
}
}- Kinds:
image,music,sfx,speech,videoandmodel3d.sdk.ai.inputs.upload(blob)sends a reference image. - Only one confirmation can be open at a time; a second call rejects with
ai_generation_in_progress. - Text and JSON generation from the browser is not available to hosted games and returns
app_ai_generation_disabled. Use a server. - Call it from a player action, during
play, and handle cancellation.
Inside a game: from a server
On a game server, playdrop.ai from @playdrop/server generates text, JSON, images, music, sound effects, speech, video and 3D. The creator pays, and owns the results by default; pass { owner: client.auth } to give an eligible result to that player.
import { playdrop } from "@playdrop/server";
const task = await playdrop.ai.speech.createTask({ input: "Welcome back, captain." }, { owner: client.auth });
// Later, once the task is DONE:
const file = await playdrop.ai.tasks.downloadFile(task.id, { role: "primary" });
client.send("speech", { bytes: new Uint8Array(await file.arrayBuffer()), contentType: file.type });- A generated file is private: download it on the server and send the bytes only to the intended player.
- Speech requests accept at most 40 words.
- Test players' generations stay owned by the creator and run in test mode.
- These calls work on uploaded games, not in local development.
Generation costs credits, so limit how often players can trigger it, and prove one complete request, from task to the player actually seeing or hearing it, before building a game around it.