image-hosting

TotalClaw 作者 totalclaw

将图像上传到 img402.dev 并获取公共 URL。免费套餐:最大 1MB,7 天 保留,无授权。当代理需要托管图像 URL 时使用 - 用于共享 在消息中、嵌入文档、发布到社交平台或任何 需要图像文件的公共链接的上下文。

安装 / 下载方式

TotalClaw CLI推荐
totalclaw install totalclaw:totalclaw~rahulgi-image-hosting
cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~rahulgi-image-hosting/file -o rahulgi-image-hosting.md
# Image Hosting — img402

Upload an image to img402.dev and get a public URL. No account, no API key, no config.

## Quick reference

```bash
# Upload (multipart)
curl -s -X POST https://img402.dev/api/free -F image=@/path/to/image.png

# Response
# {"url":"https://i.img402.dev/aBcDeFgHiJ.png","id":"aBcDeFgHiJ","contentType":"image/png","sizeBytes":182400,"expiresAt":"2026-02-17T..."}
```

## Workflow

1. **Get image**: Use an existing file, or generate/download one.
2. **Check size**: Must be under 1MB. If larger, resize:
   ```bash
   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**:
   ```bash
   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:

```bash
# Step 1: Get an upload token (requires x402 payment)
POST https://img402.dev/api/upload/token
# → {"token": "a1b2c3...", "expiresAt": "..."}

# Step 2: Upload with the token
curl -s -X POST https://img402.dev/api/upload \
  -H "X-Upload-Token: a1b2c3..." \
  -F image=@/path/to/image.png
```

See https://img402.dev/blog/paying-x402-apis for details on x402 payment.

---

## 中文说明

# Image Hosting — img402

将图像上传到 img402.dev 并获取公共 URL。无需账户、无需 API 密钥、无需配置。

## 快速参考

```bash
# Upload (multipart)
curl -s -X POST https://img402.dev/api/free -F image=@/path/to/image.png

# Response
# {"url":"https://i.img402.dev/aBcDeFgHiJ.png","id":"aBcDeFgHiJ","contentType":"image/png","sizeBytes":182400,"expiresAt":"2026-02-17T..."}
```

## 工作流

1. **获取图像**:使用现有文件,或生成/下载一个。
2. **检查大小**:必须小于 1MB。如果更大,调整大小:
   ```bash
   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. **上传**:
   ```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
# Step 1: Get an upload token (requires x402 payment)
POST https://img402.dev/api/upload/token
# → {"token": "a1b2c3...", "expiresAt": "..."}

# Step 2: Upload with the token
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。