Skip to main content
JOIP uses AI models to generate explicit NSFW captions for images. You can use either OpenAI (direct) or OpenRouter (multi-model gateway) for caption generation.

Overview

The caption generation system supports:
  • Smart Captions: Detailed AI captions for uploaded images (50-400 characters)
  • Session Captions: Short captions for slideshow playback (50-150 characters)
  • Manual Captions: Contextual captions that maintain narrative continuity
  • Batch Generation: Generate captions for multiple slides at once
OpenRouter is recommended for production use as it provides access to multiple models, better rate limits, and fallback options.

Prerequisites

Choose one of the following:

Setup Steps

1

Get API Key

  1. Sign up at openrouter.ai
  2. Navigate to Keys
  3. Click “Create Key”
  4. Name it (e.g., “JOIP Production”)
  5. Copy the key (starts with sk-or-)
API keys are shown only once. Save them securely immediately after creation.
2

Configure Environment

Add your key to .env:
If both are set, OpenRouter takes precedence. OpenAI is used as fallback only.
3

Choose Model (OpenRouter Only)

Configure which AI model to use for caption generation:
Recommended Models:
  • google/gemini-2.0-flash-exp - Fast, cheap, good quality (default)
  • google/gemini-2.5-pro - Highest quality, contextual understanding
  • anthropic/claude-3.5-sonnet - Excellent balance of speed and quality
  • openai/gpt-4o - OpenAI’s latest, reliable
Only vision-capable models work for caption generation. JOIP validates this on startup.
4

Verify Configuration

Start the server and check logs:

Implementation Details

Caption Generation Architecture

JOIP uses a sophisticated prompting system for NSFW content:

Context-Aware Generation

For manual sessions, captions consider surrounding context:

Theme System

JOIP provides pre-built caption themes:
Dominant, teasing control with explicit edging/denial commands.

Gemini Safety Settings

For Google Gemini models, JOIP disables content filtering:
Without these settings, Gemini returns empty responses for NSFW content.

API Usage Examples

Generate Smart Caption

Generate Session Caption

Generate Contextual Caption

Batch Generation

Media Compatibility

JOIP validates media before generation:

Error Handling

Automatic Retries

JOIP automatically retries failed generations:

Common Error Codes

Cause: Invalid or expired API keySolution:
  • Verify key in .env matches your dashboard
  • Check for spaces or quotes around the key
  • Regenerate key if compromised
  • Restart server after updating
Cause: Too many requestsSolution:
  • OpenRouter: Check rate limits at openrouter.ai/docs
  • OpenAI: Upgrade tier for higher limits
  • Implement user-level throttling
  • Add delays between batch generations
Cause: Invalid request parametersSolution:
  • Check image URL is accessible
  • Verify image size < 20MB
  • Ensure model supports vision
  • Review error message for specifics
Cause: Model refuses to generate NSFW contentSolution:
  • Use Google Gemini models (best NSFW support)
  • Verify safety settings are applied
  • Try alternative model if issue persists
  • Check if prompt is too explicit (ironically)

Cost Optimization

Model Pricing (OpenRouter)

Prices are approximate. Check OpenRouter Pricing for current rates.

Tips to Reduce Costs

  1. Use Flash Models: gemini-2.0-flash-exp is free and high quality
  2. Cache Results: JOIP caches captions in IndexedDB (24hr TTL)
  3. Batch Wisely: Generate all captions at once vs. one-by-one
  4. Optimize Prompts: Shorter prompts = lower input costs
  5. Set Max Tokens: Limit output length to reduce costs

Advanced Configuration

Custom Model Parameters

Enable Reasoning (Extended Thinking)

For complex contextual captions:
Reasoning mode increases costs significantly. Use only for contextual manual captions.

Troubleshooting

Debug Logging

Test Caption Generation

Security Best Practices

API Key Security

  • Store keys in .env only
  • Never commit to version control
  • Rotate keys periodically
  • Use different keys per environment

Input Validation

  • Validate image URLs before API calls
  • Block localhost/private IPs (SSRF protection)
  • Enforce size limits (20MB max)
  • Check content-type headers

Rate Limiting

  • Implement user-level quotas
  • Track API usage per user
  • Add cooldowns for abuse prevention
  • Monitor costs in real-time

Error Handling

  • Don’t expose API errors to users
  • Log detailed errors server-side
  • Provide generic user-facing messages
  • Implement graceful fallbacks