View Source Code
Browse the complete example on GitHub

Quickstart
1. Clone the repository
2. Add your API keys
Create a.env file from the template:
- Go to console.liquid.ai. If you don’t have an account yet, register and join an organization.
- Navigate to Dashboard > API Keys.
- Create a new key and copy it. Keys are prefixed with
liquid_.
Jev vs d1 mode is optional. To enable it, add an OpenRouter key as
OPENROUTER_API_KEY.3. Install dependencies and start the demo
localhost and start a race. If a key is missing, the start screen tells you which one and disables the modes that need it.
What’s inside?
The project is a vanilla JavaScript browser game with a Vite dev-server proxy:ai/ai.jsdefines the decision question, builds the game state, calls the proxy route, and normalizes the answer.game/game.jsowns the game loop, AI tick scheduling, collisions, and race results.game/road.jsandgame/items.jsgenerate identical traffic patterns for both roads.ui/renders the canvas sprites, confidence bars, HUD, and keyboard input.vite.config.jskeeps API keys server-side and forwards decision requests to Liquid or OpenRouter.
How it works
Every decision tick, the AI car does four things:- Defines a structured choice question.
- Summarizes the road ahead as a compact text state.
- Sends the state and question to the decision API.
- Applies the returned lane choice to the car.
Define the question
The game asks the model to pick one of three named lanes:type tells the model what kind of answer to return. The criteria object lists the available options.
Build the state
The AI does not receive the entire game screen. Instead, the game summarizes the nearest obstacle in each lane:Call the decision API
The browser calls a local proxy route for each racer:Interpret the response
The API returns the selected choice, per-lane probabilities, and confidence:Configuration
By default, d1 runs through Liquid’s API and Jev runs through OpenRouter:
To run d1 through OpenRouter instead of Liquid’s API:
Need help?
Join our Discord
Connect with the community and ask questions about this example.