window.ai Generative 3D Starter
Generate 3D objects in the browser with window.ai and OpenAI's shap-e.
Try the Web Demo!
- Retrieve the window.ai object from the browser
const ai = useRef(null);
useEffect(() => {
const init = async () => {
try {
const windowAI = await getWindowAI();
ai.current = windowAI;
...
} catch (error) {
...
}
};
init();
}, []);
- Supply a prompt object and numInferenceSteps, recieve a data URI
const generate3DObject = async () => {
const promptObject = { prompt: inputText };
const output = await ai.current.BETA_generate3DObject(promptObject, {
extension: "application/x-ply",
numInferenceSteps: numInferenceSteps,
});
return output[0].uri;
};
See for a more feature rich example (Neon + GCS integration for hosting models)