mirror of
https://github.com/HeyPuter/puter.git
synced 2026-09-30 00:56:50 +00:00
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test (18.x) (push) Has been cancelled
test / test (20.x) (push) Has been cancelled
test / test (22.x) (push) Has been cancelled
Puter.js
The official JavaScript SDK for Puter.com — access cloud and AI features directly from your frontend code.
Installation (npm)
npm install @heyputer/puterjs
Importing
ES Modules
import puter from '@heyputer/puterjs';
CommonJS
const puter = require('@heyputer/puterjs');
Usage Example
// Print a message
puter.print('Hello from Puter.js!');
// Chat with GPT-3.5 Turbo
puter.ai.chat('What color was Napoleon\'s white horse?').then(response => {
puter.print(response);
});
CDN Usage
Include Puter.js directly in your HTML via CDN:
<script src="https://js.puter.com/v2/"></script>
<script>
puter.print('Hello from Puter.js via CDN!');
puter.ai.chat('What color was Napoleon\'s white horse?').then(response => {
puter.print(response);
});
</script>
Documentation & Community
Local Development Example
Make sure the development server is running.
<html>
<body>
<script src="http://puter.localhost:4100/sdk/puter.dev.js"></script>
<script>
// Loading ...
puter.print(`Loading...`);
// Chat with GPT-3.5 Turbo
puter.ai.chat(`What color was Napoleon's white horse?`).then((response) => {
puter.print(response);
});
</script>
</body>
</html>