Skip to main content

Installation

npm install praisonai

Basic Usage

import { ImageAgent } from 'praisonai';

const agent = new ImageAgent();

const analysis = await agent.analyze({
  imageUrl: 'https://example.com/image.jpg',
  prompt: 'Describe this image in detail'
});

console.log(analysis);

With Configuration

import { ImageAgent } from 'praisonai';

const agent = new ImageAgent({
  name: 'VisionAgent',
  llm: 'openai/gpt-4o',
  verbose: true
});

Analyze Image

import { ImageAgent } from 'praisonai';

const agent = new ImageAgent();

const result = await agent.analyze({
  imageUrl: 'https://example.com/photo.jpg',
  prompt: 'What objects are in this image?',
  detail: 'high'
});

console.log(result);

Chat with Image Context

import { ImageAgent } from 'praisonai';

const agent = new ImageAgent();

// Chat with image
const response = await agent.chat(
  'What colors are prominent in this image?',
  'https://example.com/image.jpg'
);

// Chat without image
const textResponse = await agent.chat('What is machine learning?');

Compare Images

import { ImageAgent } from 'praisonai';

const agent = new ImageAgent();

const comparison = await agent.compare(
  'https://example.com/image1.jpg',
  'https://example.com/image2.jpg',
  'What are the differences between these images?'
);

console.log(comparison);

Detail Levels

import { ImageAgent } from 'praisonai';

const agent = new ImageAgent();

// Low detail - faster, less tokens
await agent.analyze({
  imageUrl: 'https://example.com/image.jpg',
  detail: 'low'
});

// High detail - more accurate
await agent.analyze({
  imageUrl: 'https://example.com/image.jpg',
  detail: 'high'
});

// Auto - let the model decide
await agent.analyze({
  imageUrl: 'https://example.com/image.jpg',
  detail: 'auto'
});

Factory Function

import { createImageAgent } from 'praisonai';

const agent = createImageAgent({
  name: 'MyImageAgent',
  verbose: true
});