Passport Photo Agent Skill
Passport Photo Agent Skill
Add passport photo generation capabilities to your AI agents. This skill uses the AI Pass API to create compliant passport photos for US, UK, EU, Canada, Australia, and more.
name: passport-photo description: Generate compliant passport photos using AI category: image-editing version: 1.0.0
How to Use
- Get your API key: Go to Developer Dashboard → API Keys → Create New Key
- Set environment variable:
export AIPASS_API_KEY="your-api-key-here" - Call the skill: The agent will process photos and return compliant passport images
⚠️ Note: You need a verified email address to receive payouts if you build apps using this skill.
API Reference
Generate Passport Photo
Endpoint: POST /apikey/v1/chat/completions
Request:
curl -X POST https://aipass.one/apikey/v1/chat/completions \
-H "Authorization: Bearer $AIPASS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini/gemini-3-pro-image-preview",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "Generate a compliant US passport photo. Remove background, set to white, ensure face is centered with neutral expression."},
{"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}}
]
}]
}'
Response: choices[0].message.content (image URL or base64)
Supported Country Standards
| Country | Size | Background | Model |
|---|---|---|---|
| United States | 2x2 inch (51x51mm) | White | gemini/gemini-3-pro-image-preview |
| United Kingdom | 35x45mm | Cream/light grey | gemini/gemini-3-pro-image-preview |
| European Union | 35x45mm | Light grey | gemini/gemini-3-pro-image-preview |
| Canada | 50x70mm | White | gemini/gemini-3-pro-image-preview |
| Australia | 35x45mm | Cream | gemini/gemini-3-pro-image-preview |
Skill Implementation
import base64
import os
import requests
AIPASS_API_KEY = os.environ.get("AIPASS_API_KEY")
COUNTRY_SPECS = {
"us": {
"name": "United States",
"size": "2x2 inches (51x51mm)",
"background": "white",
"prompt": "Generate a compliant US passport photo. Remove background completely. Set background to pure white. Center the face. Ensure neutral expression, eyes clearly visible, no smiling. Even lighting. 2x2 inch format."
},
"uk": {
"name": "United Kingdom",
"size": "35x45mm",
"background": "cream or light grey",
"prompt": "Generate a compliant UK passport photo. Remove background. Set background to cream or light grey. Center face. Neutral expression, mouth closed. 35x45mm format."
},
"eu": {
"name": "European Union",
"size": "35x45mm",
"background": "light grey",
"prompt": "Generate a compliant EU passport photo. Remove background. Set to light grey. Center face. Neutral expression. 35x45mm format."
},
"ca": {
"name": "Canada",
"size": "50x70mm",
"background": "white",
"prompt": "Generate a compliant Canadian passport photo. Remove background. Set to white. Center face. Neutral expression. 50x70mm format."
},
"au": {
"name": "Australia",
"size": "35x45mm",
"background": "cream",
"prompt": "Generate a compliant Australian passport photo. Remove background. Set to cream color. Center face. Neutral expression. 35x45mm format."
}
}
def generate_passport_photo(image_path, country="us"):
"""
Generate a compliant passport photo.
Args:
image_path: Path to input photo
country: Country code (us, uk, eu, ca, au)
Returns:
URL to generated passport photo
"""
if country not in COUNTRY_SPECS:
raise ValueError(f"Unsupported country: {country}")
spec = COUNTRY_SPECS[country]
# Read and encode image
with open(image_path, "rb") as f:
image_base64 = base64.b64encode(f.read()).decode()
# Prepare request
headers = {
"Authorization": f"Bearer {AIPASS_API_KEY}",
"Content-Type": "application/json"
}
payload = {
"model": "gemini/gemini-3-pro-image-preview",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": spec["prompt"]},
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{image_base64}"}}
]
}]
}
# Call API
response = requests.post(
"https://aipass.one/apikey/v1/chat/completions",
headers=headers,
json=payload
)
response.raise_for_status()
result = response.json()
# Extract image URL
content = result["choices"][0]["message"]["content"]
return content
if __name__ == "__main__":
import sys
if len(sys.argv) < 2:
print("Usage: python passport_photo.py <image_path> [country]")
print("Countries: us, uk, eu, ca, au")
sys.exit(1)
image_path = sys.argv[1]
country = sys.argv[2] if len(sys.argv) > 2 else "us"
print(f"Generating {COUNTRY_SPECS[country]['name']} passport photo...")
result_url = generate_passport_photo(image_path, country)
print(f"✅ Passport photo generated: {result_url}")
Bash Implementation
#!/bin/bash
# passport_photo.sh - Generate passport photos via AI Pass API
AIPASS_API_KEY="${AIPASS_API_KEY}"
COUNTRY="${2:-us}" # Default to US
if [ -z "$AIPASS_API_KEY" ]; then
echo "Error: AIPASS_API_KEY environment variable not set"
exit 1
fi
if [ -z "$1" ]; then
echo "Usage: ./passport_photo.sh <image_path> [country]"
echo "Countries: us, uk, eu, ca, au"
exit 1
fi
IMAGE_PATH="$1"
B64_IMAGE=$(base64 -w0 "$IMAGE_PATH")
case "$COUNTRY" in
us)
PROMPT="Generate a compliant US passport photo. Remove background completely. Set background to pure white. Center the face. Ensure neutral expression, eyes clearly visible, no smiling. Even lighting. 2x2 inch format."
;;
uk)
PROMPT="Generate a compliant UK passport photo. Remove background. Set background to cream or light grey. Center face. Neutral expression, mouth closed. 35x45mm format."
;;
eu)
PROMPT="Generate a compliant EU passport photo. Remove background. Set to light grey. Center face. Neutral expression. 35x45mm format."
;;
ca)
PROMPT="Generate a compliant Canadian passport photo. Remove background. Set to white. Center face. Neutral expression. 50x70mm format."
;;
au)
PROMPT="Generate a compliant Australian passport photo. Remove background. Set to cream color. Center face. Neutral expression. 35x45mm format."
;;
*)
echo "Error: Unsupported country '$COUNTRY'. Use: us, uk, eu, ca, au"
exit 1
;;
echo
RESPONSE=$(curl -s -X POST https://aipass.one/apikey/v1/chat/completions \
-H "Authorization: Bearer $AIPASS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini/gemini-3-pro-image-preview",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": '"$PROMPT"'},
{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,'$B64_IMAGE'"}}
]
}]
}')
echo "$RESPONSE" | python3 -c "import json,sys; print(json.load(sys.stdin)['choices'][0]['message']['content'])"
Pricing
- gpt-5-nano: Cheapest for simple tasks
- gemini/gemini-3-pro-image-preview: ~$0.02-0.05 per photo (recommended for passport photos)
- Users pay directly via AI Pass wallet
Error Handling
try:
result = generate_passport_photo("photo.jpg", "us")
print(f"Success: {result}")
except requests.exceptions.HTTPError as e:
print(f"API Error: {e}")
except ValueError as e:
print(f"Validation Error: {e}")
Best Practices
- Use high-quality input photos - Clear, well-lit photos work best
- Verify output - Check that eyes are visible and expression is neutral
- Test multiple countries - Different countries have different requirements
- Handle API errors - Implement retry logic for transient failures
- Cache results - Don't regenerate the same photo repeatedly
Testing
# Test with sample photo
export AIPASS_API_KEY="your-key"
python3 passport_photo.py sample.jpg us
# Test different countries
python3 passport_photo.py sample.jpg uk
python3 passport_photo.py sample.jpg eu
Related Resources
- Passport Photo Maker App - Live demo
- AI Pass API Docs - Full API reference
- How to Build This App - Developer tutorial
Note: This skill uses AI Pass's image editing capabilities. $1 free credit on signup for testing.
Skill File
#!/usr/bin/env python3
"""
Passport Photo Generator Skill for AI Agents
Generate compliant passport photos using AI Pass API.
Supports multiple country standards.
Requirements:
- AIPASS_API_KEY environment variable
- requests library: pip install requests
Usage:
export AIPASS_API_KEY="your-key-here"
python3 passport_photo.py <image_path> [country]
Countries: us, uk, eu, ca, au
"""
import base64
import os
import sys
import requests
AIPASS_API_KEY = os.environ.get("AIPASS_API_KEY")
COUNTRY_SPECS = {
"us": {
"name": "United States",
"size": "2x2 inches (51x51mm)",
"background": "white",
"prompt": "Generate a compliant US passport photo. Remove background completely. Set background to pure white. Center the face. Ensure neutral expression, eyes clearly visible, no smiling. Even lighting. 2x2 inch format."
},
"uk": {
"name": "United Kingdom",
"size": "35x45mm",
"background": "cream or light grey",
"prompt": "Generate a compliant UK passport photo. Remove background. Set background to cream or light grey. Center face. Neutral expression, mouth closed. 35x45mm format."
},
"eu": {
"name": "European Union",
"size": "35x45mm",
"background": "light grey",
"prompt": "Generate a compliant EU passport photo. Remove background. Set to light grey. Center face. Neutral expression. 35x45mm format."
},
"ca": {
"name": "Canada",
"size": "50x70mm",
"background": "white",
"prompt": "Generate a compliant Canadian passport photo. Remove background. Set to white. Center face. Neutral expression. 50x70mm format."
},
"au": {
"name": "Australia",
"size": "35x45mm",
"background": "cream",
"prompt": "Generate a compliant Australian passport photo. Remove background. Set to cream color. Center face. Neutral expression. 35x45mm format."
}
}
def generate_passport_photo(image_path, country="us"):
"""
Generate a compliant passport photo.
Args:
image_path: Path to input photo
country: Country code (us, uk, eu, ca, au)
Returns:
URL to generated passport photo
"""
if not AIPASS_API_KEY:
raise ValueError("AIPASS_API_KEY environment variable not set")
if country not in COUNTRY_SPECS:
raise ValueError(f"Unsupported country: {country}")
spec = COUNTRY_SPECS[country]
# Read and encode image
with open(image_path, "rb") as f:
image_base64 = base64.b64encode(f.read()).decode()
# Prepare request
headers = {
"Authorization": f"Bearer {AIPASS_API_KEY}",
"Content-Type": "application/json"
}
payload = {
"model": "gemini/gemini-3-pro-image-preview",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": spec["prompt"]},
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{image_base64}"}}
]
}]
}
# Call API
response = requests.post(
"https://aipass.one/apikey/v1/chat/completions",
headers=headers,
json=payload
)
response.raise_for_status()
result = response.json()
# Extract image URL
content = result["choices"][0]["message"]["content"]
return content
def list_countries():
"""List all supported countries."""
print("Supported countries:")
for code, spec in COUNTRY_SPECS.items():
print(f" {code}: {spec['name']} ({spec['size']})")
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Usage: python3 passport_photo.py <image_path> [country]")
print("")
list_countries()
sys.exit(1)
image_path = sys.argv[1]
country = sys.argv[2] if len(sys.argv) > 2 else "us"
print(f"Generating {COUNTRY_SPECS[country]['name']} passport photo...")
print(f" Input: {image_path}")
try:
result_url = generate_passport_photo(image_path, country)
print(f"✅ Passport photo generated: {result_url}")
except Exception as e:
print(f"❌ Error: {e}")
sys.exit(1)
Download Skill File