Developers
AirGallery API & MCP
Programmatic access to every AirGallery capability — image generation, gallery management, credits, and social — over both a REST API and a Model Context Protocol server.
Quickstart
- Sign in to AirGallery and visit /api-keys to generate a developer key. Copy the
ag_…value — it's shown once. - Make sure you have credits at /credits if you plan to call AI tools.
- Call the REST API or wire the MCP server into your agent client.
curl -X POST https://airgallery.com/functions/v1/remove-background \
-H "Authorization: Bearer ag_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "image": "data:image/png;base64,iVBORw0KG…" }'
Authentication
Every authenticated endpoint accepts a Bearer token in the Authorization header. Two token types are supported, and both work for every protected REST endpoint and MCP tool (creating, revoking and deleting API keys takes a JWT).
Developer API Key
Long-lived, scoped (read, write, ai), revocable. Best for server-side integrations, automations, and MCP clients.
Authorization: Bearer ag_abc123…
Supabase JWT
Short-lived session token from supabase.auth. Best for first-party clients that already use Supabase Auth.
Authorization: Bearer eyJhbGciOiJIUzI1NiIs…
Scopes
readBrowse public gallery, view profiles, read your own data.writeSave/delete artworks, update profile, follow/like.aiRun AI tools (deducts credits).
Missing-scope calls return 403 with { "error": "API key missing required scope: …" }. JWT-authenticated callers always have all scopes.
MCP Server
AirGallery ships an MCP server (Model Context Protocol) over Streamable HTTP. Any MCP-compatible agent — Claude Desktop, Cursor, MCP Inspector, your own LLM app — can plug in and call the same tools that power the AirGallery UI.
Listed in the official MCP Registry as com.airgallery/airgallery and on Glama:
Endpoint
https://airgallery.com/functions/v1/mcp-server
Transport: stateless Streamable HTTP. Send JSON-RPC 2.0 messages with POST; replies come back as JSON or a short SSE stream (there is no standing GET stream). Also reachable at https://airgallery.com/mcp. Protocol versions 2025-03-26 and 2025-06-18; clients on newer versions are served 2025-06-18. Messages over 4.5 MB (large base64 images, upscale_image results) need the same server at https://wgbduttegyrwiukjhubh.supabase.co/functions/v1/mcp-server.
Available tools — 60 total
Gallery (7)
- list_public_artworks
- search_artworks
- get_artwork
- list_my_artworks
- save_artwork
- update_artwork
- delete_artwork
Credits (4)
- get_credit_balance
- get_credit_costs
- get_pricing_tiers
- buy_credits
Create (1)
- create_image
AI Image Tools (27)
- remove_background
- enhance_image
- upscale_image
- text_to_image
- ai_replace
- ai_expand
- object_remover
- colorize_image
- cartoonize
- style_transfer
- relight_image
- dslr_transform
- photo_repair
- old_photo_restore
- ai_filters
- retro_transform
- polaroid_transform
- headshot_generator
- portrait_retouch
- avatar_generator
- meme_generator
- product_studio
- logo_mockup
- poster_generator
- aspect_ratio_change
- generate_tags
- studio_generate_layout
Profile & Social (7)
- get_my_profile
- update_my_profile
- get_user_profile
- follow_user
- unfollow_user
- like_artwork
- unlike_artwork
Portfolios (4)
- list_my_portfolios
- get_portfolio
- publish_portfolio
- get_public_portfolio
White-Label (2)
- list_my_white_label_galleries
- get_white_label_gallery
Design Studio (8)
- studio_list_documents
- studio_get_document
- studio_create_document
- studio_add_frames
- studio_add_elements
- studio_update_objects
- studio_delete_objects
- studio_add_font
List tools over raw HTTP
# Initialize an MCP session
curl -X POST https://airgallery.com/functions/v1/mcp-server \
-H "Authorization: Bearer ag_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}'
Connect from an MCP client
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows), then restart Claude Desktop.
{
"mcpServers": {
"airgallery": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://airgallery.com/functions/v1/mcp-server",
"--header",
"Authorization: Bearer ag_YOUR_API_KEY"
]
}
}
}
REST: AI Tool Endpoints
Each AI tool is its own edge function under https://airgallery.com/functions/v1/<name>. All accept POST with a JSON body. All require auth (API keys need the ai scope) and consume credits; generate-tags is free the first time for one of your own untagged artworks. Credits are charged when the call starts and refunded automatically if it fails.
airgallery.com accepts request and response bodies up to 4.5 MB. For larger images (up to 25 MB), and for topaz-upscale, which returns the full-size image inline, call the same function at https://wgbduttegyrwiukjhubh.supabase.co/functions/v1/<name> with the same headers and body.
/image-transform Core multi-modal transform (powers Create); pick a model, cost depends on it
/remove-background Remove image background (transparent PNG, or a solid colour with bg_color)
/enhance-image General clean-up, sharpen, denoise or fix lighting
/object-remover Remove objects painted over in red
/ai-replace Replace an area painted over in red with new content
/ai-expand Outpaint / extend image boundaries
/ai-filters Apply artistic AI filters
/aspect-ratio Change aspect ratio, filling new space with AI
/cartoonize Convert photos to cartoon / anime
/colorize-image Add color to B&W photos
/dslr-transform Professional DSLR camera look
/headshot-generator Generate professional headshots
/logo-mockup Place a logo on realistic mockups
/meme-generator Memes with custom text
/old-photo-restore Restore vintage photographs
/photo-repair Fix blur, noise or low resolution
/polaroid-transform Classic instant-photo effect
/portrait-retouch Enhance and retouch portraits
/poster-generator Create poster / flyer layouts
/product-studio E-commerce product photography
/relight-image Change scene lighting
/retro-image Retro/vintage film effects
/style-transfer Repaint a photo in the style of a second image
/text-to-image Generate images from text
/topaz-upscale Topaz AI upscaling, 1–6x or to an exact outputWidth / outputHeight
/studio-layout Design a layout from a brief: a frame and positioned text, shape and image layers for Design Studio
/avatar-generator Stylized AI avatars from a photo
/generate-tags Auto-generate descriptive tags (free the first time for a saved artwork)
Images can be passed as base64 data URIs (data:image/png;base64,…) or as HTTPS URLs. Responses return the result image (a data URI or URL) as processedImage, image or generatedImage depending on the tool; errors return { "error": "…" }. The MCP tool descriptions list each tool's fields and allowed values.
image-transform models
Body: { "images": [ …up to 5 ], "customPrompt": "…", "preset": "none", "model": "nano-banana-2" }. Send images, a prompt, or both. Every model accepts reference images except recraft-v4.1 recraft-v4.1-flash, which is text-to-image only (images return a 400, refunded). Also accepted over the API: gpt-image-mini (GPT Image 1 Mini, 3 cr).
nano-banana-2Nano Banana 23 crnano-banana-2-liteNano Banana 2 Lite2 crnano-banana-proNano Banana Pro6 crgpt-image-2.6-flareGPT Image 2.6 Flare8 crgpt-image-2.6-sunburstGPT Image 2.6 Sunburst8 crflux-3FLUX 33 crflux-3-kleinFLUX 3 Klein1 crmai-image-2.7MAI-Image 2.73 crmai-image-2.7-flashMAI-Image 2.7 Flash1 crgrok-imagine-2Grok Imagine 2.04 crseedream-5.5Seedream 5.52 crseedream-5-proSeedream 5.0 Pro2 crmuse-imageMuse Image1 crminimax-h3MiniMax H32 crrecraft-v4.1Recraft V4.12 crrecraft-v4.1-flashRecraft V4.1 Flash1 crmai-image-2.6MAI-Image 2.63 crgpt-image-2.5-flareGPT Image 2.5 Flare8 crgpt-image-2.5-sunburstGPT Image 2.5 Sunburst8 crgpt-imageGPT Image 28 crnano-bananaNano Banana3 cr
remove.bg-compatible API
remove.bg's website and self-service API close on December 1, 2026. To move code written for their API, change the URL to POST https://airgallery.com/v1.0/removebg and put an AirGallery ag_… key in the same X-Api-Key header. Each call costs 1 credit, refunded if it fails.
- Input:
image_file,image_file_b64orimage_url, as multipart form data, a urlencoded form or JSON. bg_color(a hex like81d4faor a color name) puts the subject on a solid color.size,type,cropandchannelsare accepted and ignored.formatmust beautoorpng;bg_image_urlisn't supported.- Output: the PNG bytes, or
{ "data": { "result_b64": "…" } }when you sendAccept: application/json, withX-Credits-Charged,X-WidthandX-Heightheaders. - Errors use remove.bg's shape:
{ "errors": [{ "title": "…", "code": "auth_failed" }] }. - Uploads over 4.5 MB: use
https://wgbduttegyrwiukjhubh.supabase.co/functions/v1/remove-background/v1.0/removebg(up to 25 MB), or passimage_url.
# Before: https://api.remove.bg/v1.0/removebg with your remove.bg key
curl -H "X-Api-Key: ag_YOUR_API_KEY" \
-F "image_file=@photo.jpg" \
-F "size=auto" \
-f https://airgallery.com/v1.0/removebg -o no-bg.png
REST: Credits API
Single endpoint POST https://airgallery.com/functions/v1/credits — the operation is selected by an action field in the body. A missing or unknown action returns 400.
Get the authenticated user's credit balance.
Request:
{ "action": "balance" }
Response:
{ "balances": [{ "credit_type_id": "...", "credit_type_name": "AirGallery", "credit_type_symbol": "AG", "balance": 42 }] }
Retrieve available credit packages and pricing. Public: no auth needed.
Request:
{ "action": "pricing-tiers" }
Response:
{ "pricing_tiers": [{ "id": "...", "name": "Starter", "price": 5, "credits": 50, "currency": "USD" }] }
Create a Stripe checkout session for purchasing credits. success_url and cancel_url are optional (default: /credits).
Request:
{ "action": "checkout", "pricing_tier_id": "tier_xxx", "success_url": "https://…", "cancel_url": "https://…" }
Response:
{ "url": "https://checkout.stripe.com/..." }
Register or sync the current user with the credits system. Grants the one-time signup credits on first call, except to disposable email addresses and past two new accounts per network per day (then welcome_credits is 0 and welcome_skipped is "disposable_email" or "ip_limit").
Request:
{ "action": "sync-user", "name": "Jane Doe" }
Response:
{ "success": true, "welcome_credits": 10 }
REST: API Key Management
Single endpoint POST https://airgallery.com/functions/v1/api-keys — selected by the action field. Use the API Keys dashboard for a UI, or call these directly to automate key rotation. An ag_ key can list keys; creating, revoking and deleting them needs a signed-in session token (Supabase JWT), and an API key gets a 403.
Create a new developer API key (max 10 active per user). Returned key shown only once. JWT-only.
Request:
{ "action": "create", "name": "My App", "scopes": ["read","write","ai"], "expires_in_days": 90 }
Response:
{ "success": true, "api_key": "ag_xxx…", "key_prefix": "ag_xxx…", "scopes": ["read","write","ai"], "expires_at": "2025-…" }
List the caller's API keys (does not return the secret). Works for JWT or API-key callers.
Request:
{ "action": "list" }
Response:
{ "keys": [{ "id": "…", "name": "…", "key_prefix": "ag_…", "scopes": ["read"], "is_active": true }] }
Disable an API key without deleting it. JWT-only — an API key cannot revoke siblings.
Request:
{ "action": "revoke", "key_id": "uuid" }
Response:
{ "success": true }
Permanently delete an API key. JWT-only.
Request:
{ "action": "delete", "key_id": "uuid" }
Response:
{ "success": true }
Errors & Rate Limits
Rate Limits
Per-IP, 5–120 requests/min depending on endpoint. 429 includes Retry-After in seconds.
Credit Deduction
Credits are charged when a tool run starts and refunded automatically if it fails, so failed operations cost nothing.
Idempotency
AI calls are not idempotent — outputs are non-deterministic. Cache responses client-side if you need stability.
原文来源:airgallery.com