
Show HN:remove.bg API 的即插即用替代方案,该 API 将于 12 月 1 日关停
来源标题:Show HN: Drop-in replacement for the remove.bg API, which shuts down Dec 1
通过 REST API 和模型上下文协议(MCP)服务器,以编程方式访问 AirGallery 的全部能力——图像生成、图库管理、积分和社交功能。
以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。
Programmatic access to every AirGallery capability — image generation, gallery management, credits, and social — over both a REST API and a Model Context Protocol server.
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).
Long-lived, scoped (read, write, ai), revocable. Best for server-side integrations, automations, and MCP clients.
Short-lived session token from supabase.auth. Best for first-party clients that already use Supabase Auth.
Missing-scope calls return 403 with { "error": "API key missing required scope: …" }. JWT-authenticated callers always have all scopes.
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:
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.
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
Claude DesktopCursorMCP Inspector
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows), then restart Claude Desktop.
json
{ "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.
Core multi-modal transform (powers Create); pick a model, cost depends on it
Remove image background (transparent PNG, or a solid colour with bg_color)
General clean-up, sharpen, denoise or fix lighting
Replace an area painted over in red with new content
Change aspect ratio, filling new space with AI
Repaint a photo in the style of a second image
Topaz AI upscaling, 1–6x or to an exact outputWidth / outputHeight
Design a layout from a brief: a frame and positioned text, shape and image layers for Design Studio
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.
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.1recraft-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).
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.
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.
{ "balances": [{ "credit_type_id": "...", "credit_type_name": "AirGallery", "credit_type_symbol": "AG", "balance": 42 }] }
POST/credits→ action: "pricing-tiers"
Retrieve available credit packages and pricing. Public: no auth needed.
{ "pricing_tiers": [{ "id": "...", "name": "Starter", "price": 5, "credits": 50, "currency": "USD" }] }
POST/credits→ action: "checkout"
Create a Stripe checkout session for purchasing credits. success_url and cancel_url are optional (default: /credits).
{ "action": "checkout", "pricing_tier_id": "tier_xxx", "success_url": "https://…", "cancel_url": "https://…" }
Response:
{ "url": "https://checkout.stripe.com/..." }
POST/credits→ action: "sync-user"
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").
{ "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.
{ "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-…" }
POST/api-keys→ action: "list"
List the caller's API keys (does not return the secret). Works for JWT or API-key callers.
{ "keys": [{ "id": "…", "name": "…", "key_prefix": "ag_…", "scopes": ["read"], "is_active": true }] }
POST/api-keys→ action: "revoke"
Disable an API key without deleting it. JWT-only — an API key cannot revoke siblings.
{ "action": "revoke", "key_id": "uuid" }
Response:
{ "success": true }
POST/api-keys→ action: "delete"
Permanently delete an API key. JWT-only.
{ "action": "delete", "key_id": "uuid" }
Response:
{ "success": true }
Errors & Rate Limits
400Bad request — missing required field or invalid value, or the model's safety filter blocked the prompt or the image it generated (credits refunded; try another prompt or model).
401Unauthorized — missing or invalid Bearer token.
402Insufficient credits — purchase more at /credits.
403Forbidden — API key is missing the required scope.
404Resource not found.
413Payload too large (25 MB max per image; 4.5 MB per request on airgallery.com, see REST: AI Tool Endpoints).
429Rate limited — see Retry-After header.
422The model answered without an image (for example, nothing to edit); the message explains why and credits are refunded.
500Internal server error — try again; it is recorded on our side.
Rate Limits
Per-IP, 5–120 requests/min depending on endpoint. 429 includes Retry-After in seconds.
Credits are charged when a tool run starts and refunded automatically if it fails, so failed operations cost nothing.
AI calls are not idempotent — outputs are non-deterministic. Cache responses client-side if you need stability.
正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。
