{"id":49834291,"url":"https://github.com/fqueis/pollinationsai","last_synced_at":"2026-05-13T23:40:23.310Z","repository":{"id":282483572,"uuid":"944831291","full_name":"fqueis/pollinationsai","owner":"fqueis","description":"🔥 TypeScript SDK wrapper for Pollinations AI services","archived":false,"fork":false,"pushed_at":"2025-03-21T20:01:51.000Z","size":94,"stargazers_count":13,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-30T10:28:26.949Z","etag":null,"topics":["ai-client","api-wrapper","image-generation-ai","pollinations-ai","speech-to-text","text-completion","text-to-speech","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fqueis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-08T03:51:32.000Z","updated_at":"2025-08-25T16:53:22.000Z","dependencies_parsed_at":"2025-03-14T23:26:37.367Z","dependency_job_id":"f1a1d657-fa3f-45e9-8526-094a3e0d5624","html_url":"https://github.com/fqueis/pollinationsai","commit_stats":null,"previous_names":["fqueis/pollinationsai"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/fqueis/pollinationsai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fqueis%2Fpollinationsai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fqueis%2Fpollinationsai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fqueis%2Fpollinationsai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fqueis%2Fpollinationsai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fqueis","download_url":"https://codeload.github.com/fqueis/pollinationsai/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fqueis%2Fpollinationsai/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33004764,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"ssl_error","status_checked_at":"2026-05-13T13:14:51.610Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-client","api-wrapper","image-generation-ai","pollinations-ai","speech-to-text","text-completion","text-to-speech","typescript"],"created_at":"2026-05-13T23:40:21.997Z","updated_at":"2026-05-13T23:40:23.303Z","avatar_url":"https://github.com/fqueis.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🐝 Pollinations AI Client Library\n\n![npm](https://img.shields.io/npm/v/pollinationsai) ![License](https://img.shields.io/npm/l/pollinationsai) ![TypeScript](https://img.shields.io/badge/TypeScript-✓-blue)\n\nA TypeScript/JavaScript client for interacting with Pollinations AI services, providing easy access to image generation, text processing, and speech synthesis capabilities.\n\n## Features\n\n- 🖼️ Image generation with multiple models and parameters\n- 🔊 Text-to-speech conversion with voice selection\n- 📝 AI-powered text completions\n- 🔧 Builder pattern API for easy request construction\n- ⚡ Axios-based HTTP client with extensible architecture\n- ✅ 100% test coverage with Jest\n- 📦 Dual CJS/ESM module support\n\n## Installation\n\n```bash\nnpm install pollinationsai\n# or\npnpm add pollinationsai\n# or\nyarn add pollinationsai\n```\n\n## Module Support\n\nThis library supports both modern ESM and legacy CommonJS environments:\n\n**ESM Usage:**\n\n```javascript\nimport { createImageService } from \"pollinationsai\"\n```\n\n**CommonJS Usage:**\n\n```javascript\nconst { createImageService } = require(\"pollinationsai\")\n```\n\n## Type Safety\n\n- 🛡️ Full TypeScript support with strict type checking\n- 📜 Detailed type definitions included in package\n- 🔍 Compile-time validation of all API parameters\n\n## Usage Examples\n\n### Image Generation Features\n\n##### Basic Generation\n\n```typescript\nimport { createImageService } from \"pollinationsai\"\nimport fs from \"fs\"\n\n// Create service with default client\nconst imageService = createImageService()\n\nconst prompt = \"A mystical forest with glowing mushrooms\"\n\n// Generate image from prompt\nconst imageStream = await imageService.generateImage(prompt, {\n    model: \"flux\",\n    width: 1024,\n    height: 1024,\n    private: true,\n    safe: true,\n    seed: 42,\n    nologo: true,\n    enhance: true,\n})\n\n// Save buffer to file\nfs.writeFileSync(\"magic-forest.jpg\", imageBuffer)\n```\n\n##### Model Management\n\n```typescript\n// List available models\nconst models = await imageService.listModels()\nconsole.log(\"Available models:\", models)\n```\n\n### Text Generation Features\n\n##### Basic Completion\n\n```typescript\nimport { PollinationsTextService } from \"pollinationsai\"\n\nconst textService = new PollinationsTextService()\n\n// Simple GET-based generation\nconst prompt = \"Once upon a time in a cyberpunk city...\"\n\nconst story = await textService.getGenerate(prompt, {\n    model: \"openai-large\",\n    system: \"You are a evil helpful assistant.\",\n    private: true,\n})\n```\n\n##### Advanced Chat Completion\n\n```typescript\n// Complex POST request with message history\nconst chatHistory = await textService.postGenerate({\n    model: \"openai-large\",\n    messages: [\n        { role: \"system\", content: \"You are a sarcastic assistant\" },\n        { role: \"user\", content: \"How do I make a sandwich?\" },\n    ],\n    seed: 12345,\n})\n```\n\n##### Advanced Chat Completion with stream support\n\n```typescript\n// Complex POST request with message history\n\n// using callback pattern\nconst onStreamData = (event) =\u003e console.log(event);\n\nconst stream = await textService.postGenerate({\n    model: \"openai-large\",\n    messages: [\n        { role: \"system\", content: \"You are a sarcastic assistant\" },\n        { role: \"user\", content: \"How do I make a sandwich?\" },\n    ],\n    seed: 12345,\n}, { stream: true, onStreamData: onStreamData })\n\n// using native stream pattern\nstream\n    .on(\"data\", (event) =\u003e console.log(event))\n    .on(\"end\", () =\u003e console.log(\"Stream complete\"))\n    .on(\"error\", (err) =\u003e console.error(\"Stream error:\", err));\n```\n\n##### Multimodal Vision Processing\n\n```typescript\n// Image analysis with vision model\nconst imageAnalysis = await textService.vision({\n    model: \"openai-large\",\n    private: true\n    messages: [{\n        role: \"user\",\n        content: [\n            { type: \"text\", text: \"What's in this image?\" },\n            {\n                type: \"image_url\",\n                image_url: {\n                    url: \"https://example.com/sample.jpg\",\n                },\n            },\n        ],\n    }]\n})\n```\n\n##### Real-time Streaming\n\n```typescript\n// Subscribe to real-time text generation feed\nconst cleanup = textService.subscribeToFeed(\n    (event) =\u003e console.log(\"New generated text:\", event.response)\n    (error) =\u003e console.error(\"Stream error:\", error)\n)\n\n// Remember to cleanup when you're done\nsetTimeout(() =\u003e cleanup(), 60000)\n```\n\n##### Model Management\n\n```typescript\n// List available models\nconst models = await textService.listModels()\nconsole.log(\"Available models:\", models)\n```\n\n### Speech Features\n\n### Text-to-Speech\n\n##### Basic Usage:\n\n```typescript\nimport { PollinationsSpeechService } from \"pollinationsai\"\nimport fs from \"fs\"\n\nconst speechService = new PollinationsSpeechService()\n\nconst text = \"Exploring the vastness of space requires courage and curiosity\"\n\n// Simple text-to-speech conversion\nconst audio = await speechService.pollinationsTextToSpeech({ text, voice: \"nova\", format: \"mp3\" })\n\nfs.writeFileSync(\"space.mp3\", audio)\n```\n\n##### OpenAI-compatible API:\n\n```typescript\nconst content = \"The future belongs to those who believe in the beauty of their dreams\"\n\n// Advanced TTS with message history\nconst dreams = await speechService.openAITextToSpeech({\n    voice: \"ash\",\n    format: \"wav\",\n    messages: [{ role: \"user\", content }],\n  });\n\nfs.writeFileSync(\"dreams.wav\", dreams.choices[0].message.audio.data, { encoding: \"base64\" });\n```\n\n### Speech-to-Text\n\n##### Only OpenAI-compatible API:\n\n```typescript\nconst audio = fs.readFileSync(\"dreams.wav\", { encoding: \"base64\" });\n\n// Convert speech to text\nconst transcription = await speechService.openAISpeechToText({\n    messages: [{\n        role: \"user\",\n        content: [\n          { type: \"text\", text: \"What is in this recording?\" },\n          { type: \"input_audio\", input_audio: { data: audio, format: \"wav\" } },\n        ],\n    }]\n})\n\nconsole.log(\"Transcription:\", transcription.choices[0].message.content)\n```\n\n### Builder Pattern Example\n\n```typescript\nimport { TextGenerationGetRequestBuilder } from \"pollinationsai\"\n\nconst baseUrl = \"https://text.pollinations.ai\"\n\nconst url = new TextGenerationGetRequestBuilder(baseUrl)\n    .setPrompt(\"Once upon a time in a cyberpunk city...\")\n    .setModel(\"openai-large\")\n    .setSeed(1234)\n    .setJsonMode(true)\n    .setSystem(\"You are a evil helpful assistant\")\n    .setPrivateMode(true)\n    .build()\n\nconst generatedText = await fetch(url).then((r) =\u003e r.json())\n```\n\n## Development Setup\n\n```bash\n# Run tests (with coverage)\nnpm test\n\n# Watch mode development\nnpm run tests:watch\n\n# Build both ESM and CJS versions\nnpm run build\n```\n\n## Contributing\n\n🤝 We welcome contributions! Please follow these steps:\n\n1. Fork the repository\n2. Create a feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## License\n\nOpen-source software licensed under the [MIT license](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffqueis%2Fpollinationsai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffqueis%2Fpollinationsai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffqueis%2Fpollinationsai/lists"}