Image Hosting — img402
Upload an image to img402.dev and get a public URL. No account, no API key, no config.
Quick reference
CODEBLOCK0
Workflow
- 1. Get image: Use an existing file, or generate/download one.
- Check size: Must be under 1MB. If larger, resize:
sips -Z 1600 /path/to/image.png # macOS — scale longest edge to 1200px
convert /path/to/image.png -resize 1600x1600 /path/to/image.png # ImageMagick
- 3. Upload:
curl -s -X POST https://img402.dev/api/free -F image=@/path/to/image.png
- 4. Use the URL: The
url field in the response is a public CDN link. Embed it wherever needed.
Constraints
- - Max size: 1MB
- Retention: 7 days
- Formats: PNG, JPEG, GIF, WebP
- Rate limit: 1,000 free uploads/day (global)
- No auth required
Paid tier
For images that need to persist longer (1 year, 5MB max), use the paid endpoint at $0.01 USDC via x402:
CODEBLOCK3
See https://img402.dev/blog/paying-x402-apis for details on x402 payment.
图片托管 — img402
上传图片至 img402.dev 并获取公开 URL。无需账户、无需 API 密钥、无需配置。
快速参考
bash
上传(multipart 格式)
curl -s -X POST https://img402.dev/api/free -F image=@/path/to/image.png
响应
{url:https://i.img402.dev/aBcDeFgHiJ.png,id:aBcDeFgHiJ,contentType:image/png,sizeBytes:182400,expiresAt:2026-02-17T...}
工作流程
- 1. 获取图片:使用现有文件,或生成/下载一个。
- 检查大小:必须小于 1MB。若超出,请调整尺寸:
bash
sips -Z 1600 /path/to/image.png # macOS — 将最长边缩放至 1200px
convert /path/to/image.png -resize 1600x1600 /path/to/image.png # ImageMagick
- 3. 上传:
bash
curl -s -X POST https://img402.dev/api/free -F image=@/path/to/image.png
- 4. 使用 URL:响应中的 url 字段为公开 CDN 链接,可嵌入任何需要的位置。
限制条件
- - 最大大小:1MB
- 保留期限:7 天
- 支持格式:PNG、JPEG、GIF、WebP
- 速率限制:每天 1,000 次免费上传(全局)
- 无需认证
付费套餐
如需图片长期保存(最长 1 年,最大 5MB),可通过 x402 使用付费端点,费用为 0.01 USDC:
bash
步骤 1:获取上传令牌(需通过 x402 支付)
POST https://img402.dev/api/upload/token
→ {token: a1b2c3..., expiresAt: ...}
步骤 2:使用令牌上传
curl -s -X POST https://img402.dev/api/upload \
-H X-Upload-Token: a1b2c3... \
-F image=@/path/to/image.png
关于 x402 支付的详细信息,请参阅 https://img402.dev/blog/paying-x402-apis。