Skip to content

Quickstart

This guide gets you from a local browser game to a playable Vifu cloud game.

1. Sign Up And Log In

Create a Vifu account at vifu.ai.

Install the CLI, then sign in from your terminal:

bash
curl -fsSL https://vifu.dev/cli | bash
vifu login

Use the same email and password you used on vifu.ai. The CLI stores a local login token for deploys.

2. Create Or Choose A Project

Create a starter project:

bash
npm create @vifu/vifu my-game -- --template vanilla --no-interactive
cd my-game

Or use an existing browser game:

bash
cd path/to/your-game
vifu setup
vifu deploy

setup detects the project and asks you to confirm the game name and detected build settings. Override only when detection is wrong. If you skip this step, deploy starts the same setup flow before it builds. In CI, use vifu deploy --yes to accept detected defaults without prompts.

3. Try The Examples

The examples repository is the fastest way to see what a good Vifu project looks like:

bash
git clone --recurse-submodules https://github.com/vifu-labs/vifu-examples
cd vifu-examples

Start with:

Each example has its own README. From an example folder, run:

bash
vifu deploy

4. Add The SDK

npm

Use npm when the project has a bundler or build step:

bash
npm install @vifu/sdk@alpha
ts
import { createVifuSDK } from "@vifu/sdk";

const vifu = createVifuSDK();
await vifu.ready();

CDN

Load the browser build from jsDelivr. Deployed games should use an exact SDK version:

html
<script src="https://cdn.jsdelivr.net/npm/@vifu/[email protected]/dist/browser/vifu-sdk.js"></script>
<script>
  const vifu = window.vifu;
</script>

5. Call Vifu AI

ts
const result = await vifu.ai.generateText({
  model: "basic",
  messages: [
    { role: "user", content: "Give the player a short hint." }
  ]
});

showHint(result.content);

Use basic for low-cost gameplay text and simple classification. Use quality for story turns or more complex reasoning. Games do not choose backend provider names or ship provider API keys.

Vifu AI is available through the SDK by default. Do not add a manifest entry for normal vifu.ai.generateText(...) calls.

6. Deploy

bash
vifu deploy

vifu deploy runs setup if needed, validates the project, builds the game, checks the output, uploads only when the build changed, and prints a playable URL.

If deploy is blocked, read the file, line, URL, and fix in the error message. The most common causes are remote JavaScript imports or direct external AI/API calls left in the browser bundle.

For deployment flags and game management commands, see the Deployment section.

Local Behavior

Outside Vifu, managed AI, save state, and other Vifu platform capabilities may be unavailable. The game should still load and remain playable with a local fallback.