Files
puter/src/docs/src/examples.js
T
Hemant 69bb7e4a38
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
Notify HeyPuter / notify (push) Has been cancelled
release-please / release-please (push) Has been cancelled
Close #2718 : added querying with prefix patterns example and documentation (#2778)
* feat: add querying with prefix patterns example and documentation

* refine

---------

Co-authored-by: Reynaldi Chernando <reynaldichernando@gmail.com>
2026-04-08 13:49:00 +07:00

661 lines
34 KiB
JavaScript

const examples = [
{
title: 'Introduction',
children: [
{
title: 'Hello World',
description: 'Try Puter.js instantly with interactive examples in your browser. Run, edit, and experiment with code - no installation or setup required.',
slug: '',
source: '/playground/examples/intro-chatgpt.html',
},
{
title: 'Image Analysis',
description: 'Analyze images with AI using Puter.js. Run and experiment with this GPT Vision example directly in the playground.',
slug: 'intro-gpt-vision',
source: '/playground/examples/intro-gpt-vision.html',
},
{
title: 'Cloud Storage',
description: 'Write files to cloud storage with Puter.js filesystem API. Run and modify this code example instantly in your browser.',
slug: 'intro-fs-write',
source: '/playground/examples/intro-fs-write.html',
},
{
title: 'Key-Value Store',
description: 'Store and retrieve data with Puter.js key-value API. Run and experiment with this working code in the playground.',
slug: 'intro-kv-set',
source: '/playground/examples/intro-kv-set.html',
},
{
title: 'Publish a Website',
description: 'Deploy websites instantly with Puter.js hosting API. Run and modify this example to publish your own site directly in the playground.',
slug: 'intro-hosting',
source: '/playground/examples/intro-hosting.html',
},
{
title: 'Authentication',
description: 'Implement user authentication with Puter.js auth API. Run and experiment with this sign-in example in the playground.',
slug: 'intro-auth',
source: '/playground/examples/intro-auth.html',
},
],
},
{
title: 'AI',
children: [
{
title: 'Chat with GPT-5 nano',
description: 'Chat with GPT-5 nano using Puter.js AI API. Run and experiment with this chatbot example directly in the playground.',
slug: 'ai-chatgpt',
source: '/playground/examples/ai-chatgpt.html',
},
{
title: 'Image Analysis',
description: 'Analyze images with AI using Puter.js GPT Vision API. Run and modify this code example instantly in your browser.',
slug: 'ai-gpt-vision',
source: '/playground/examples/ai-gpt-vision.html',
},
{
title: 'Video Analysis',
description: 'Analyze videos with AI using Puter.js. Run and modify this video analysis example instantly in your browser.',
slug: 'ai-video-analysis',
source: '/playground/examples/ai-video-analysis.html',
},
{
title: 'Stream the response',
description: 'Stream AI chat responses in real-time with Puter.js. Run and experiment with this streaming example in the playground.',
slug: 'ai-chat-stream',
source: '/playground/examples/ai-chat-stream.html',
},
{
title: 'Function Calling',
description: 'Try AI function calling with Puter.js. Run and experiment with this advanced example directly in the playground.',
slug: 'ai-function-calling',
source: '/playground/examples/ai-function-calling.html',
},
{
title: 'Streaming Function Calls',
description: 'Run AI function calling with streaming using Puter.js. Try out AI examples directly in Puter.js playground.',
slug: 'ai-streaming-function-calling',
source: '/playground/examples/ai-streaming-function-calling.html',
},
{
title: 'Web Search',
description: 'Perform web search using AI to generate accurate and up-to-date information. Try out this example in Puter.js playground.',
slug: 'ai-web-search',
source: '/playground/examples/ai-web-search.html',
},
{
title: 'AI Resume Analyzer (File handling)',
description: 'Try an AI resume analyzer with file handling and GPT integration. Run and experiment with this Puter.js example directly in your browser.',
slug: 'ai-resume-analyzer',
source: '/playground/examples/ai-resume-analyzer.html',
},
{
title: 'Chat with OpenAI o3-mini',
description: 'Chat with OpenAI o3-mini using Puter.js AI API. Run and experiment with this example directly in the playground.',
slug: 'ai-chat-openai-o3-mini',
source: '/playground/examples/ai-chat-openai-o3-mini.html',
},
{
title: 'Chat with Claude Sonnet',
description: 'Chat with Claude Sonnet using Puter.js AI API. Run and experiment with this example directly in the playground.',
slug: 'ai-chat-claude',
source: '/playground/examples/ai-chat-claude.html',
},
{
title: 'Prompt caching with Claude',
description: 'Reduce time and costs with Claude prompt caching using Puter.js AI API. Try AI examples directly in Puter.js playground.',
slug: 'ai-claude-cache-control',
source: '/playground/examples/ai-claude-cache-control.html',
},
{
title: 'Chat with DeepSeek',
description: 'Chat with DeepSeek using Puter.js AI API. Run and experiment with this example directly in the playground.',
slug: 'ai-chat-deepseek',
source: '/playground/examples/ai-chat-deepseek.html',
},
{
title: 'Chat with Gemini',
description: 'Chat with Google Gemini using Puter.js AI API. Run and experiment with this example directly in the playground.',
slug: 'ai-chat-gemini',
source: '/playground/examples/ai-chat-gemini.html',
},
{
title: 'Chat with xAI (Grok)',
description: 'Chat with xAI Grok using Puter.js AI API. Run and experiment with this example directly in the playground.',
slug: 'ai-xai',
source: '/playground/examples/ai-xai.html',
},
{
title: 'Extract Text from Image',
description: 'Extract text from images using Puter.js AI API. Run and modify this OCR example instantly in your browser.',
slug: 'ai-img2txt',
source: '/playground/examples/ai-img2txt.html',
},
{
title: 'Text to Image',
description: 'Generate images from text with Puter.js AI API. Run and experiment with this text-to-image example in the playground.',
slug: 'ai-txt2img',
source: '/playground/examples/ai-txt2img.html',
},
{
title: 'Text to Image with options',
description: 'Generate images with custom options using Puter.js AI API. Run and experiment with advanced text-to-image parameters in the playground.',
slug: 'ai-txt2img-options',
source: '/playground/examples/ai-txt2img-options.html',
},
{
title: 'Text to Image with image-to-image generation',
description: 'Transform images with AI using Puter.js image-to-image generation. Run and experiment with this example directly in the playground.',
slug: 'ai-txt2img-image-to-image',
source: '/playground/examples/ai-txt2img-image-to-image.html',
},
{
title: 'Text to Speech',
description: 'Convert text to speech with Puter.js AI API. Run and experiment with this TTS example directly in the playground.',
slug: 'ai-txt2speech',
source: '/playground/examples/ai-txt2speech.html',
},
{
title: 'Text to Speech with options',
description: 'Generate speech with custom voice options using Puter.js AI API. Run and experiment with advanced TTS parameters in the playground.',
slug: 'ai-txt2speech-options',
source: '/playground/examples/ai-txt2speech-options.html',
},
{
title: 'Text to Speech with engines',
description: 'Try different TTS engines with Puter.js AI API. Run and compare speech synthesis options directly in the playground.',
slug: 'ai-txt2speech-engines',
source: '/playground/examples/ai-txt2speech-engines.html',
},
{
title: 'Text to Speech with OpenAI',
description: 'Generate speech with OpenAI voices using Puter.js AI API. Run and experiment with this TTS example in the playground.',
slug: 'ai-txt2speech-openai',
source: '/playground/examples/ai-txt2speech-openai.html',
},
{
title: 'Text to Speech with ElevenLabs',
description: 'Generate speech with ElevenLabs voices using Puter.js AI API. Run and experiment with this TTS example in the playground.',
slug: 'ai-txt2speech-elevenlabs',
source: '/playground/examples/ai-txt2speech-elevenlabs.html',
},
{
title: 'Voice Changer',
description: 'Swap a sample clip into a new voice using Puter.js AI speech-to-speech helpers.',
slug: 'ai-voice-changer',
source: '/playground/examples/ai-voice-changer.html',
},
{
title: 'ElevenLabs Voice changer with a sample clip',
description: 'Transform an audio clip into a new voice using Puter.js speech-to-speech helper.',
slug: 'ai-speech2speech-url',
source: '/playground/examples/ai-speech2speech-url.html',
},
{
title: 'ElevenLabs Voice changer with a recording stored as a file',
description: 'Transform an audio clip into a new voice using Puter.js speech-to-speech helper.',
slug: 'ai-speech2speech-file',
source: '/playground/examples/ai-speech2speech-file.html',
},
{
title: 'Transcribe an audio recording into text',
description: 'Transcribe an audio recording into text using Puter.js AI API. Run and experiment with this example directly in the playground.',
slug: 'ai-speech2txt',
source: '/playground/examples/ai-speech2txt.html',
},
{
title: 'Text to Video',
description: 'Generate videos from text with Puter.js AI API. Run and experiment with this text-to-video example in the playground.',
slug: 'ai-txt2vid',
source: '/playground/examples/ai-txt2vid.html',
},
{
title: 'Text to Video with options',
description: 'Generate videos with custom options using Puter.js AI API. Run and experiment with advanced text-to-video parameters in the playground.',
slug: 'ai-txt2vid-options',
source: '/playground/examples/ai-txt2vid-options.html',
},
{
title: 'List AI models',
description: 'Retrieve the available AI chat models (and providers) in Puter.js. Try out this example directly in the playground.',
slug: 'ai-list-models',
source: '/playground/examples/ai-list-models.html',
},
{
title: 'List AI model providers',
description: 'Retrieve the available AI providers that Puter currently exposes. Try out this example directly in the playground.',
slug: 'ai-list-model-providers',
source: '/playground/examples/ai-list-model-providers.html',
},
],
},
{
title: 'FileSystem',
children: [
{
title: 'Write File',
description: 'Write files to cloud storage with Puter.js filesystem API. Run and modify this code example instantly in your browser.',
slug: 'fs-write',
source: '/playground/examples/fs-write.html',
},
{
title: 'Read File',
description: 'Read files from cloud storage with Puter.js filesystem API. Run and experiment with this code example in the playground.',
slug: 'fs-read',
source: '/playground/examples/fs-read.html',
},
{
title: 'Make a Directory',
description: 'Create directories with Puter.js filesystem API. Run and modify this code example instantly in your browser.',
slug: 'fs-mkdir',
source: '/playground/examples/fs-mkdir.html',
},
{
title: 'Delete',
description: 'Delete files with Puter.js filesystem API. Run and experiment with this code example directly in the playground.',
slug: 'fs-delete',
source: '/playground/examples/fs-delete.html',
},
{
title: 'Read Directory',
description: 'List directory contents with Puter.js filesystem API. Run and modify this code example instantly in your browser.',
slug: 'fs-readdir',
source: '/playground/examples/fs-readdir.html',
},
{
title: 'Rename',
description: 'Rename files and directories with Puter.js filesystem API. Run and experiment with this code example in the playground.',
slug: 'fs-rename',
source: '/playground/examples/fs-rename.html',
},
{
title: 'Get File/Directory Info',
description: 'Get file metadata with Puter.js filesystem API. Run and modify this stat example instantly in your browser.',
slug: 'fs-stat',
source: '/playground/examples/fs-stat.html',
},
{
title: 'Copy File/Directory',
description: 'Copy files and directories with Puter.js filesystem API. Run and experiment with this code example in the playground.',
slug: 'fs-copy',
source: '/playground/examples/fs-copy.html',
},
{
title: 'Move File/Directory',
description: 'Move files and directories with Puter.js filesystem API. Run and modify this code example instantly in your browser.',
slug: 'fs-move',
source: '/playground/examples/fs-move.html',
},
{
title: 'Upload',
description: 'Upload files with Puter.js filesystem API. Run and experiment with this file upload example directly in the playground.',
slug: 'fs-upload',
source: '/playground/examples/fs-upload.html',
},
{
title: 'Write a file with deduplication',
description: 'Write files with automatic deduplication using Puter.js. Run and experiment with this example directly in the playground.',
slug: 'fs-write-dedupe',
source: '/playground/examples/fs-write-dedupe.html',
},
{
title: 'Create a new file with input coming from a file input',
description: 'Create files from file input elements with Puter.js. Run and experiment with this example directly in the playground.',
slug: 'fs-write-from-input',
source: '/playground/examples/fs-write-from-input.html',
},
{
title: 'Create a file in a directory that does not exist',
description: 'Write files with automatic parent directory creation using Puter.js. Run and experiment with this example in the playground.',
slug: 'fs-write-create-missing-parents',
source: '/playground/examples/fs-write-create-missing-parents.html',
},
{
title: 'Create a directory with deduplication',
description: 'Create directories with automatic deduplication using Puter.js. Run and modify this code example instantly in your browser.',
slug: 'fs-mkdir-dedupe',
source: '/playground/examples/fs-mkdir-dedupe.html',
},
{
title: 'Create a directory with missing parent directories',
description: 'Create nested directories automatically with Puter.js. Run and experiment with this example directly in the playground.',
slug: 'fs-mkdir-create-missing-parents',
source: '/playground/examples/fs-mkdir-create-missing-parents.html',
},
{
title: 'Move a file with missing parent directories',
description: 'Move files with automatic parent directory creation using Puter.js. Run and experiment with this example in the playground.',
slug: 'fs-move-create-missing-parents',
source: '/playground/examples/fs-move-create-missing-parents.html',
},
{
title: 'Delete a directory',
description: 'Delete directories with Puter.js filesystem API. Run and modify this code example instantly in your browser.',
slug: 'fs-delete-directory',
source: '/playground/examples/fs-delete-directory.html',
},
],
},
{
title: 'Key-Value Store',
children: [
{
title: 'Set',
description: 'Store data with Puter.js key-value API. Run and experiment with this set example directly in the playground.',
slug: 'kv-set',
source: '/playground/examples/kv-set.html',
},
{
title: 'Get',
description: 'Retrieve data with Puter.js key-value API. Run and modify this get example instantly in your browser.',
slug: 'kv-get',
source: '/playground/examples/kv-get.html',
},
{
title: 'Increment',
description: 'Increment numeric values with Puter.js key-value API. Run and experiment with this example in the playground.',
slug: 'kv-incr',
source: '/playground/examples/kv-incr.html',
},
{
title: 'Increment (Object value)',
description: 'Increment nested values in objects with Puter.js key-value API. Run and experiment with this example in the playground.',
slug: 'kv-incr-nested',
source: '/playground/examples/kv-incr-nested.html',
},
{
title: 'Decrement',
description: 'Decrement numeric values with Puter.js key-value API. Run and modify this code example instantly in your browser.',
slug: 'kv-decr',
source: '/playground/examples/kv-decr.html',
},
{
title: 'Add',
description: 'Add values to existing keys with Puter.js key-value API. Run and experiment with this example directly in the playground.',
slug: 'kv-add',
source: '/playground/examples/kv-add.html',
},
{
title: 'Remove',
description: 'Remove values by path with Puter.js key-value API. Run and modify this code example instantly in your browser.',
slug: 'kv-remove',
source: '/playground/examples/kv-remove.html',
},
{
title: 'Update',
description: 'Update nested paths in stored values with Puter.js key-value API. Run and experiment with this example in the playground.',
slug: 'kv-update',
source: '/playground/examples/kv-update.html',
},
{
title: 'Decrement (Object value)',
description: 'Decrement nested values in objects with Puter.js key-value API. Run and experiment with this example in the playground.',
slug: 'kv-decr-nested',
source: '/playground/examples/kv-decr-nested.html',
},
{
title: 'Delete',
description: 'Delete key-value pairs with Puter.js API. Run and experiment with this delete example directly in the playground.',
slug: 'kv-del',
source: '/playground/examples/kv-del.html',
},
{
title: 'List',
description: 'List all keys with Puter.js key-value API. Run and modify this code example instantly in your browser.',
slug: 'kv-list',
source: '/playground/examples/kv-list.html',
},
{
title: 'List (Pagination)',
description: 'Paginate key-value results with a cursor and limit using puter.kv.list(). Run and modify this example in the playground.',
slug: 'kv-list-pagination',
source: '/playground/examples/kv-list-pagination.html',
},
{
title: 'List (Sorted)',
description: 'See how keys are returned in lexicographic order with puter.kv.list(). Run and modify this example in the playground.',
slug: 'kv-list-sort',
source: '/playground/examples/kv-list-sort.html',
},
{
title: 'List (Zero-Padding)',
description: 'Learn how to sort numeric keys correctly by zero-padding. Run and experiment with this example in the playground.',
slug: 'kv-list-padding',
source: '/playground/examples/kv-list-padding.html',
},
{
title: 'List (Prefix Patterns)',
description: 'Learn how to model SQL-style filtering in Puter.js KV by designing keys for prefix queries. Run and modify this example in the playground.',
slug: 'kv-prefix-patterns',
source: '/playground/examples/kv-prefix-patterns.html',
},
{
title: 'Flush',
description: 'Clear all data with Puter.js key-value API. Run and experiment with this flush example in the playground.',
slug: 'kv-flush',
source: '/playground/examples/kv-flush.html',
},
{
title: 'Expire',
description: 'Set the time-to-live (TTL) in seconds for a key in the key-value store. Run and experiment with this expire example in the playground.',
slug: 'kv-expire',
source: '/playground/examples/kv-expire.html',
},
{
title: 'Expire At',
description: 'Set the expiration timestamp (in seconds) for a key in the key-value store. Run and experiment with this expire example in the playground.',
slug: 'kv-expireAt',
source: '/playground/examples/kv-expireAt.html',
},
{
title: "What's your name?",
description: 'Try a simple name storage app with Puter.js key-value API. Run and experiment with this interactive example in the playground.',
slug: 'kv-name',
source: '/playground/examples/kv-name.html',
},
],
},
{
title: 'Networking',
children: [
{
title: 'Basic TCP Socket',
description: 'Create TCP socket connections with Puter.js networking API. Run and experiment with this example directly in the playground.',
slug: 'net-basic',
source: '/playground/examples/net-basic.html',
},
{
title: 'TLS Socket',
description: 'Create secure TLS connections with Puter.js networking API. Run and modify this code example instantly in your browser.',
slug: 'net-tls',
source: '/playground/examples/net-tls.html',
},
{
title: 'Fetch',
description: 'Make HTTP requests with Puter.js fetch API. Run and experiment with this example directly in the playground.',
slug: 'net-fetch',
source: '/playground/examples/net-fetch.html',
},
],
},
{
title: 'Peer',
children: [
{
title: 'Peer Chat',
description: 'Create a peer-to-peer data channel with Puter.js. Run and experiment with this example directly in the playground.',
slug: 'peer-basic',
source: '/playground/examples/peer-basic.html',
},
],
},
{
title: 'Hosting',
children: [
{
title: 'Create a simple website displaying "Hello world!"',
description: 'Deploy a simple website instantly with Puter.js hosting API. Run and experiment with this example directly in the playground.',
slug: 'hosting-create',
source: '/playground/examples/hosting-create.html',
},
{
title: 'Create 3 random websites and then list them',
description: 'Create and list multiple websites with Puter.js hosting API. Run and modify this code example instantly in your browser.',
slug: 'hosting-list',
source: '/playground/examples/hosting-list.html',
},
{
title: 'Create a random website then delete it',
description: 'Deploy and delete websites with Puter.js hosting API. Run and experiment with this example in the playground.',
slug: 'hosting-delete',
source: '/playground/examples/hosting-delete.html',
},
{
title: 'Update a subdomain to point to a new directory',
description: 'Update website subdomains with Puter.js hosting API. Run and modify this code example instantly in your browser.',
slug: 'hosting-update',
source: '/playground/examples/hosting-update.html',
},
{
title: 'Retrieve information about a subdomain',
description: 'Get website information with Puter.js hosting API. Run and experiment with this example directly in the playground.',
slug: 'hosting-get',
source: '/playground/examples/hosting-get.html',
},
],
},
{
title: 'Authentication',
children: [
{
title: 'Sign in',
description: 'Implement user sign-in with Puter.js auth API. Run and experiment with this authentication example in the playground.',
slug: 'auth-sign-in',
source: '/playground/examples/auth-sign-in.html',
},
{
title: 'Sign out',
description: 'Sign out users with Puter.js auth API. Run and modify this code example instantly in your browser.',
slug: 'auth-sign-out',
source: '/playground/examples/auth-sign-out.html',
},
{
title: 'Check sign in',
description: 'Check authentication status with Puter.js auth API. Run and experiment with this example directly in the playground.',
slug: 'auth-is-signed-in',
source: '/playground/examples/auth-is-signed-in.html',
},
{
title: 'Get user',
description: 'Retrieve user information with Puter.js auth API. Run and modify this code example instantly in your browser.',
slug: 'auth-get-user',
source: '/playground/examples/auth-get-user.html',
},
{
title: "Get user's monthly usage",
description: 'Get user usage statistics with Puter.js auth API. Run and experiment with this example directly in the playground.',
slug: 'auth-get-monthly-usage',
source: '/playground/examples/auth-get-monthly-usage.html',
},
],
},
{
title: 'Apps',
children: [
{
title: 'To-Do List',
description: 'Try a complete to-do list app built with Puter.js. Run, edit, and experiment with this working example in the playground.',
slug: 'app-todo',
source: '/playground/examples/app-todo.html',
},
{
title: 'AI Chat',
description: 'Try a complete AI chat app built with Puter.js. Run, edit, and experiment with this working example in the playground.',
slug: 'app-ai-chat',
source: '/playground/examples/app-ai-chat.html',
},
{
title: 'Camera Photo Describer',
description: 'Try a camera app with AI image analysis built with Puter.js. Run and experiment with this working example in the playground.',
slug: 'app-camera',
source: '/playground/examples/app-camera.html',
},
{
title: 'Text Summarizer',
description: 'Try an AI text summarizer app built with Puter.js. Run, edit, and experiment with this working example in the playground.',
slug: 'app-summarizer',
source: '/playground/examples/app-summarizer.html',
},
{
title: 'Create an app pointing to example.com',
description: 'Create app registrations with Puter.js apps API. Run and experiment with this example directly in the playground.',
slug: 'app-create',
source: '/playground/examples/app-create.html',
},
{
title: 'Create 3 random apps and then list them',
description: 'Create and list app registrations with Puter.js apps API. Run and modify this code example instantly in your browser.',
slug: 'app-list',
source: '/playground/examples/app-list.html',
},
{
title: 'Create a random app then delete it',
description: 'Create and delete app registrations with Puter.js apps API. Run and experiment with this example in the playground.',
slug: 'app-delete',
source: '/playground/examples/app-delete.html',
},
{
title: 'Create a random app then change its title',
description: 'Update app registrations with Puter.js apps API. Run and modify this code example instantly in your browser.',
slug: 'app-update',
source: '/playground/examples/app-update.html',
},
{
title: 'Create a random app then get it',
description: 'Get app information with Puter.js apps API. Run and experiment with this example directly in the playground.',
slug: 'app-get',
source: '/playground/examples/app-get.html',
},
],
},
{
title: 'Workers',
children: [
{
title: 'Create a worker',
description: 'Deploy serverless workers with Puter.js workers API. Run and experiment with this example directly in the playground.',
slug: 'workers-create',
source: '/playground/examples/workers-create.html',
},
{
title: 'List workers',
description: 'List all workers with Puter.js workers API. Run and modify this code example instantly in your browser.',
slug: 'workers-list',
source: '/playground/examples/workers-list.html',
},
{
title: 'Get a worker',
description: 'Get worker information with Puter.js workers API. Run and experiment with this example in the playground.',
slug: 'workers-get',
source: '/playground/examples/workers-get.html',
},
{
title: 'Workers Management',
description: 'Manage workers with Puter.js workers API. Run and modify this complete management example instantly in your browser.',
slug: 'workers-management',
source: '/playground/examples/workers-management.html',
},
{
title: 'Authenticated Worker Requests',
description: 'Execute authenticated worker requests with Puter.js workers API. Run and experiment with this example in the playground.',
slug: 'workers-exec',
source: '/playground/examples/workers-exec.html',
},
],
},
];
module.exports = examples;