Install Puter.js using NPM or include it directly via CDN.
npm install @heyputer/puter.js
import { puter } from "@heyputer/puter.js";
// Example: Use AI to answer a question
puter.ai.chat(`Why did the chicken cross the road?`).then(console.log);
import { init } from "@heyputer/puter.js/src/init.cjs";
const puter = init(process.env.puterAuthToken);
// Example: Use AI to answer a question
puter.ai.chat("What color was Napoleon's white horse?").then(console.log);
<script src="https://js.puter.com/v2/"></script>
<html>
<body>
<script src="https://js.puter.com/v2/"></script>
<script>
puter.ai.chat(`Why did the chicken cross the road?`).then(puter.print);
</script>
</body>
</html>
Additionally, you can use one of the following starter templates to get started:
To learn more about the capabilities of Puter.js and how to use them in your web application, check out
Tutorials: Step-by-step guides to help you get started with Puter.js and build powerful applications.
Playground: Experiment with Puter.js in your browser and see the results in real-time. Many examples are available to help you understand how to use Puter.js effectively.
Examples: A collection of code snippets and full applications that demonstrate how to use Puter.js to solve common problems and build innovative applications.