Package Exports
- projectai
 - projectai/index.js
 
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (projectai) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ProjectAI
A modern JavaScript library for AI-powered text and image generation using the Project API.
Features
- Text & chat completion
 - Image generation from text
 - Unified, simple API
 - Works with Node.js
 
Installation
npm install projectaiQuick Usage
const { ProjectModel } = require('projectai');
const client = new ProjectModel('YOUR_API_KEY');
client.responses.create({
  model: 'project-model-2.0',
  input: 'Tell me a joke about cats.'
}).then(res => {
  console.log(res.text);
});
client.responses.create({
  model: 'project-model-2.0',
  input: [
    { role: 'user', message: 'Hi' }
  ]
}).then(res => {
  console.log(res.text);
});
client.responses.create({
  model: 'project-image',
  input: 'A robot playing chess with a cat'
}).then(res => {
  require('fs').writeFileSync('img.png', Buffer.from(res.imageBase64, 'base64'));
  console.log('Image saved as img.png');
});API
new ProjectModel(apiKey)
Create a new client instance.
client.responses.create(options)
Unified method for text, chat, and image generation.
Text/Chat
model:"project-model-2.0"or"project-model"input: string or array of{ role, message }
Image
model:"project-image"input: string prompt
Returns
- For text: 
{ text: string } - For image: 
{ imageBase64: string, text?: string } 
Endpoints Used
POST /api/generate-image(for images)POST /api/generate(for text/chat)
Authentication
Pass your API key as the first argument to ProjectModel or set the PROJECT_AI_API_KEY environment variable.
Example: Full Flow
const { ProjectModel } = require('projectai');
const client = new ProjectModel('YOUR_API_KEY');
client.responses.create({
  model: 'project-model-2.0',
  input: 'Summarize the history of AI in one sentence.'
}).then(res => console.log(res.text));
client.responses.create({
  model: 'project-image',
  input: 'A futuristic city at sunset'
}).then(res => require('fs').writeFileSync('city.png', Buffer.from(res.imageBase64, 'base64')));📝 License
MIT
MIT License
Copyright (c) 2025 Project AI Library
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.