@aivue/image-caption

AI-powered image captioning for Vue.js applications using Hugging Face BLIP models
658 17
Install
npm install @aivue/image-caption
Latest Version:1.0.6
Vue:2 · 3
License:MIT
Last Updated:Oct 25, 2026
Links: GitHub  ·  npm
Maintainer: aivue

VueAI

VueAI architecture. One repository, the agent runtime, and every feature.

@aivue/image-caption

npm version License: MIT Vue 3 TypeScript

🖼️ AI-powered image captioning for Vue.js applications using OpenAI Vision API

Generate intelligent, contextual captions for images using GPT-4 Vision, the most advanced computer vision model available. Perfect for accessibility, content management, social media, and AI-powered applications.

✨ Features

  • 🤖 GPT-4 Vision - Most advanced image understanding AI
  • 🎯 Easy Integration - Drop-in Vue component with minimal setup
  • 🔑 Simple Authentication - Just add your OpenAI API key
  • 📱 Drag & Drop Upload - Intuitive file upload with preview
  • 🌐 URL Support - Caption images from URLs
  • 📊 Batch Processing - Process multiple images at once
  • 📈 History Tracking - Keep track of generated captions
  • 💾 Export Data - Export captions as JSON or CSV
  • 🎨 Beautiful UI - Modern, responsive design
  • 🔧 TypeScript Support - Full type definitions included
  • 📱 Mobile Friendly - Works great on all devices

🚀 Quick Start

Installation

npm install @aivue/image-caption

Basic Usage

<template>
  <div>
    <AiImageCaption
      :api-key="openaiApiKey"
      @caption-generated="onCaptionGenerated"
    />
  </div>
</template>

<script setup>
import { AiImageCaption } from '@aivue/image-caption';
import '@aivue/image-caption/dist/image-caption.css';

const openaiApiKey = import.meta.env.VITE_OPENAI_API_KEY;

const onCaptionGenerated = (result) => {
  console.log('Generated caption:', result.caption);
};
</script>

Environment Variables

Set your API key in environment variables:

# .env
VITE_OPENAI_API_KEY=your-openai-api-key

📖 API Reference

Component Props

Prop Type Default Description
apiKey string '' OpenAI API key
model string 'gpt-6.1-sol' AI model to use
autoCaption boolean false Auto-generate caption on image upload
maxHistorySize number 20 Maximum number of captions to keep in history

Component Events

Event Payload Description
caption-generated ImageCaptionResult Fired when caption is successfully generated
caption-error Error Fired when caption generation fails
image-uploaded ImageUploadEvent Fired when image is uploaded
image-removed void Fired when image is removed

Composable Usage

<script setup>
import { useImageCaption } from '@aivue/image-caption';

const {
  generateCaption,
  uploadImage,
  isProcessing,
  result,
  error,
  history
} = useImageCaption({
  config: {
    apiKey: import.meta.env.VITE_OPENAI_API_KEY,
    model: 'gpt-6.1-sol'
  }
});

// Generate caption for uploaded file
const handleFileUpload = async (file) => {
  try {
    await uploadImage(file);
    const result = await generateCaption(file);
    console.log('Caption:', result.caption);
  } catch (error) {
    console.error('Failed:', error);
  }
};
</script>

🎯 Available Models

Model ID Description Best For
GPT-6.1 Sol gpt-6.1-sol Current flagship vision model General use, highest quality
GPT-5.6 Sol gpt-5.6-sol Previous flagship, still on chat completions Longer analysis
GPT-4o gpt-4o Earlier vision model, leaving the API in January 2027 Existing apps

🔧 Configuration Options

interface ImageCaptionConfig {
  apiKey?: string;                    // OpenAI API key
  model?: string;                     // Model ID to use ('gpt-6.1-sol', 'gpt-5.6-sol', 'gpt-4o')
}

interface ImageCaptionOptions {
  model?: string;                     // Override model for this request
  prompt?: string;                    // Custom prompt for caption generation
  detail?: 'low' | 'high' | 'auto';   // Image analysis detail level
  maxTokens?: number;                 // Maximum response tokens (300)
  temperature?: number;               // Creativity level (0.7)
}

🎨 Styling

The component comes with beautiful default styles, but you can customize them:

/* Override default styles */
.ai-image-caption {
  --primary-color: #your-color;
  --border-radius: 12px;
  --spacing: 16px;
}

/* Custom upload area */
.upload-area {
  border: 2px dashed #your-color;
  background: #your-background;
}

/* Custom button styles */
.generate-btn {
  background: linear-gradient(135deg, #your-gradient);
}

📊 Advanced Usage

Batch Processing

<script setup>
import { useImageCaption } from '@aivue/image-caption';

const { generateBatchCaptions } = useImageCaption();

const processBatch = async (imageFiles) => {
  const result = await generateBatchCaptions({
    images: imageFiles,
    options: {
      model: 'gpt-6.1-sol',
      prompt: 'Describe this image in detail for accessibility purposes.',
      detail: 'high'
    }
  });

  console.log(`Processed ${result.successCount} images`);
  console.log('Results:', result.results);
};
</script>

Custom Image Processing

<script setup>
import { useImageCaption, resizeImageFile } from '@aivue/image-caption';

const { generateCaption } = useImageCaption();

const processLargeImage = async (file) => {
  // Resize large images for faster processing
  const resizedFile = await resizeImageFile(file, {
    maxWidth: 800,
    maxHeight: 600,
    quality: 0.8
  });
  
  const result = await generateCaption(resizedFile);
  return result;
};
</script>

Export History

<script setup>
import { useImageCaption } from '@aivue/image-caption';

const { exportHistory, history } = useImageCaption();

const downloadHistory = () => {
  const jsonData = exportHistory('json');
  const blob = new Blob([jsonData], { type: 'application/json' });
  const url = URL.createObjectURL(blob);
  
  const a = document.createElement('a');
  a.href = url;
  a.download = 'image-captions.json';
  a.click();
  
  URL.revokeObjectURL(url);
};
</script>

🔑 Getting Your API Key

  1. Go to OpenAI Platform
  2. Sign up for an account
  3. Go to API Keys
  4. Create a new secret key
  5. Copy your key (starts with "sk-") and use it as your API key

Pricing:

  • GPT-4o: $5.00 / 1M input tokens, $15.00 / 1M output tokens
  • GPT-4o Mini: $0.15 / 1M input tokens, $0.60 / 1M output tokens
  • GPT-4 Turbo: $10.00 / 1M input tokens, $30.00 / 1M output tokens

🌟 Examples

Accessibility Enhancement

<template>
  <div>
    <img :src="https://raw.githubusercontent.com/reachbrt/VueAI/HEAD/imageUrl" :alt="altText" />
    <AiImageCaption 
      :api-key="apiKey"
      @caption-generated="updateAltText"
    />
  </div>
</template>

<script setup>
const altText = ref('');

const updateAltText = (result) => {
  altText.value = result.caption;
};
</script>

Social Media Integration

<template>
  <div class="social-post">
    <AiImageCaption 
      :api-key="apiKey"
      :auto-caption="true"
      @caption-generated="suggestHashtags"
    />
    <textarea v-model="postText" placeholder="Write your post..."></textarea>
  </div>
</template>

<script setup>
const postText = ref('');

const suggestHashtags = (result) => {
  const hashtags = generateHashtags(result.caption);
  postText.value += `\n\n${hashtags}`;
};
</script>

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Explore the complete @aivue ecosystem:

🧠 @aivue/core

Core AI functionality for Vue.js components

💬 @aivue/chatbot

AI-powered chat components for Vue.js

✨ @aivue/autosuggest

AI-powered suggestion components for Vue.js

📝 @aivue/smartform

AI-powered form validation for Vue.js

🎭 @aivue/emotion-ui

Emotion-aware UI components with sentiment analysis

📄 @aivue/doc-intelligence

Document processing and OCR with AI

🧠 @aivue/predictive-input

AI-powered predictive text input

🔔 @aivue/smart-notify

Intelligent notification system

🎤 @aivue/voice-actions

Voice command integration

📋 @aivue/smart-datatable

Advanced data table components

📊 @aivue/analytics

AI-powered analytics and insights

📄 License

MIT License - see LICENSE for details.


Made with ❤️ by reachbrt

Related Packages

@aivue/core

Core AI functionality for Vue.js components

7,407 17
@aivue/tabular-intelligence

The most comprehensive tabular data analysis package for Vue.js - Advanced AI, M...

3,107 17
@ai-sdk/vue
25,274,128 27,537
lxrt

Local AI infrastructure for agent frameworks - Transformers.js wrapper with LLM,...

788 0
@siemens/ix-mcp-vue

iX MCP server for Vue

20,690

Version History

Version Released Vue License
1.0.6 ^2.6.0 || ^3.0.0 MIT
1.0.5 ^2.6.0 || ^3.0.0 MIT
1.0.4 ^2.6.0 || ^3.0.0 MIT
1.0.3 ^2.6.0 || ^3.0.0 MIT
1.0.2 ^3.0.0 MIT