AI
Pass

Photo Enhancer Agent Skill - AI Pass API

Photo Enhancer Agent Skill - AI Pass API

Learn how to add AI photo enhancement to your AI agent using the AI Pass API. This skill handles image uploads, quality enhancement, and downloads with proper error handling.

Skill Overview

This skill enables your agent to:

  • Accept image files from users
  • Enhance photo quality using AI
  • Return the enhanced image URL
  • Handle various image formats

Prerequisites

  • AI Pass API Key: Get yours at Developer Dashboard
  • Valid email address (required for API key verification and payouts)

Skill Content

Copy this skill definition into your agent's skill system:

name: photo-enhancer
version: 1.0.0
description: Enhance photo quality with AI using AI Pass API
category: image-processing

# Set this to your AI Pass API key
# Get your key: https://aipass.one/panel/developer.html
api_key: $AIPASS_API_KEY

# Base URL for AI Pass API
base_url: https://aipass.one/apikey/v1

# Model for image enhancement
model: gemini/gemini-3-pro-image-preview

endpoints:
  enhance_photo:
    method: POST
    path: /chat/completions
    description: Enhance photo quality using AI
    headers:
      Authorization: Bearer $api_key
      Content-Type: application/json
    body:
      model: $model
      messages:
        - role: user
          content:
            - type: text
              text: Enhance this photo quality. Improve sharpness, reduce noise, fix lighting issues, and adjust contrast for better visual appeal. Return only the enhanced image URL.
            - type: image_url
              image_url:
                url: $base64_image

# Supported image formats
formats:
  - jpg
  - jpeg
  - png
  - webp

# Size limits (in bytes)
max_file_size: 10485760  # 10MB

instructions: |
  Photo Enhancer Skill
  
  Usage:
  1. User provides an image file (JPG, PNG, WEBP, up to 10MB)
  2. Convert image to base64 if needed
  3. Call enhance_photo endpoint with base64 data
  4. Return enhanced image URL to user
  
  Examples:
  - "Enhance this photo: [upload photo.jpg]"
  - "Make this image look sharper: [upload screenshot.png]"
  - "Improve the quality of this picture"
  
  Notes:
  - The AI model accepts base64-encoded images
  - Include "data:image/[format];base64," prefix in the URL
  - Response contains the enhanced image URL in text format
  - Handle errors gracefully (invalid file, API failures)

Python Implementation

import requests
import base64
import os

class PhotoEnhancer:
    """AI Pass Photo Enhancer for AI Agents"""
    
    def __init__(self, api_key):
        self.api_key = api_key
        self.base_url = "https://aipass.one/apikey/v1"
        self.model = "gemini/gemini-3-pro-image-preview"
        self.max_size = 10 * 1024 * 1024  # 10MB
    
    def enhance_photo(self, image_path):
        """Enhance photo quality using AI
        
        Args:
            image_path: Path to image file (JPG, PNG, WEBP)
            
        Returns:
            Enhanced image URL string
            
        Raises:
            ValueError: If file is invalid or too large
            Exception: If API call fails
        """
        # Validate file
        if not os.path.exists(image_path):
            raise ValueError(f"File not found: {image_path}")
        
        file_size = os.path.getsize(image_path)
        if file_size > self.max_size:
            raise ValueError(f"File too large: {file_size} bytes (max: {self.max_size})")
        
        # Read and convert to base64
        with open(image_path, 'rb') as f:
            image_data = f.read()
        
        # Detect MIME type
        ext = image_path.rsplit('.', 1)[-1].lower()
        mime_types = {
            'jpg': 'image/jpeg',
            'jpeg': 'image/jpeg',
            'png': 'image/png',
            'webp': 'image/webp'
        }
        mime_type = mime_types.get(ext, 'image/jpeg')
        
        # Create base64 URL
        base64_data = base64.b64encode(image_data).decode('utf-8')
        base64_url = f"data:{mime_type};base64,{base64_data}"
        
        # Call AI Pass API
        response = requests.post(
            f"{self.base_url}/chat/completions",
            headers={
                "Authorization": f"Bearer {self.api_key}",
                "Content-Type": "application/json"
            },
            json={
                "model": self.model,
                "messages": [{
                    "role": "user",
                    "content": [
                        {
                            "type": "text",
                            "text": "Enhance this photo quality. Improve sharpness, reduce noise, fix lighting issues, and adjust contrast for better visual appeal. Return only the enhanced image URL."
                        },
                        {
                            "type": "image_url",
                            "image_url": {
                                "url": base64_url
                            }
                        }
                    ]
                }]
            }
        )
        
        if response.status_code != 200:
            raise Exception(f"API error: {response.status_code} - {response.text}")
        
        # Extract image URL from response
        result = response.json()
        content = result['choices'][0]['message']['content']
        
        # Parse URL from response text
        import re
        url_match = re.search(r'https?://[^\s\)]+\.(png|jpg|jpeg|webp)' , content)
        
        if not url_match:
            raise Exception("No image URL found in response")
        
        return url_match.group(0)


# Usage Example
if __name__ == "__main__":
    # Initialize with your API key
    enhancer = PhotoEnhancer(api_key=os.environ.get("AIPASS_API_KEY"))
    
    # Enhance a photo
    try:
        enhanced_url = enhancer.enhance_photo("input.jpg")
        print(f"Enhanced photo: {enhanced_url}")
    except Exception as e:
        print(f"Error: {e}")

Getting Your API Key

  1. Sign up at https://aipass.one
  2. Go to Developer Dashboard
  3. Click "API Keys"
  4. Create a new key
  5. Copy the key (starts with sk-aikey-...)

Important: Never hardcode API keys in your skill. Use $AIPASS_API_KEY environment variable or a secure configuration system.

API Reference

Endpoint: POST /chat/completions

Used for image editing with vision-capable models.

Headers:

  • Authorization: Bearer $AIPASS_API_KEY
  • Content-Type: application/json

Body:

{
  "model": "gemini/gemini-3-pro-image-preview",
  "messages": [{
    "role": "user",
    "content": [
      {"type": "text", "text": "Enhance this photo..."},
      {"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,..."}}
    ]
  }]
}

Response:

{
  "choices": [{
    "message": {
      "content": "https://cdn.aipass.one/enhanced/abc123.jpg"
    }
  }]
}

Supported Models

  • gemini/gemini-3-pro-image-preview — Best for image editing (recommended)
  • gemini/gemini-2.5-flash-image-preview — Faster, cheaper

Error Handling

Common errors and solutions:

Error Cause Solution
401 Unauthorized Invalid API key Check $AIPASS_API_KEY is set correctly
400 Bad Request Invalid image format Use JPG, PNG, or WEBP
413 Payload Too Large File exceeds 10MB Compress or resize image
500 Internal Server Error API issue Retry after a few seconds

Testing

Test your skill implementation:

# Set your API key
export AIPASS_API_KEY="your-key-here"

# Run the Python script
python3 photo_enhancer.py input.jpg

# Check the result

Integration Tips

  • Batch processing: Call enhance_photo() in a loop for multiple files
  • Progress tracking: Show processing status for better UX
  • Caching: Cache enhanced results to avoid re-processing
  • Validation: Check file format and size before API calls
  • Error recovery: Implement retry logic for transient failures

Developer Dashboard: https://aipass.one/panel/developer.html Related App: AI Photo Enhancer