# Agent Image Compression API

> Agent Image Compression API is a paid API for AI agents from agent-image-compress-production.up.railway.app, paid per call via x402, $0.005/call, status unknown (last checked 2026-09-13).

Compresses and converts uploaded images to WebP format, returning the compressed image as base64 with size savings metrics, billed per-image via x402/USDC micropayment.

## Facts

- Endpoint: POST https://agent-image-compress-production.up.railway.app/api/compress-upload
- Price: $0.005/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/agent-image-compression-api-841d02c8
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_EpyQX8VN_8tZQ2ryxraHP

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability agent-image-compression-api-841d02c8 -d '<json body>'
```

Example prompt: Can you compress this image I'm uploading and convert it to WebP so I can see how many bytes it saves? I want the compressed image back as base64.

## When to prefer this

Choose this endpoint when an AI agent needs to compress individual images on a pay-per-use basis without a subscription, especially in automated pipelines where x402 micropayments (USDC) are already supported. Ideal when WebP output format and base64 encoding are acceptable, and when size reduction metrics (percent saved, byte counts) are needed alongside the compressed image.

## Known failure modes

- Invalid or unsupported image format — returns error response
- Payment not provided or rejected via x402 — returns 402 Payment Required
- Image too large or malformed upload — returns 400 Bad Request
- Server unavailable on Railway deployment — returns 503 or timeout
- Empty or missing image body — returns error indicating no file received

## How this service works

Pay-per-image compression for AI agents (x402 + MPP).

## Output

A JSON object containing: the compressed image as a base64-encoded WebP string, the output image width and height in pixels, input and output byte sizes, percent of bytes saved, and the content type ('image/webp').

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method",
    "bodyType",
    "body"
   ],
   "properties": {
    "body": {
     "properties": {}
    },
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "POST",
      "PUT",
      "PATCH"
     ],
     "type": "string"
    },
    "bodyType": {
     "enum": [
      "json",
      "form-data",
      "text"
     ],
     "type": "string"
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "$schema": "https://json-schema.org/draft/2020-12/schema",
     "required": [
      "format",
      "contentType",
      "inputBytes",
      "outputBytes",
      "percentSaved",
      "width",
      "height",
      "image"
     ],
     "properties": {
      "image": {
       "type": "string",
       "description": "Base64-encoded compressed image bytes."
      },
      "width": {
       "type": "integer",
       "maximum": 9007199254740991,
       "minimum": -9007199254740991,
       "description": "Output width in px."
      },
      "format": {
       "enum": [
        "png",
        "jpeg",
        "webp",
        "avif"
       ],
       "type": "string",
       "description": "Output image format."
      },
      "height": {
       "type": "integer",
       "maximum": 9007199254740991,
       "minimum": -9007199254740991,
       "description": "Output height in px."
      },
      "inputBytes": {
       "type": "integer",
       "maximum": 9007199254740991,
       "minimum": -9007199254740991,
       "description": "Source size in bytes."
      },
      "contentType": {
       "type": "string",
       "description": "MIME type of the returned image."
      },
      "outputBytes": {
       "type": "integer",
       "maximum": 9007199254740991,
       "minimum": -9007199254740991,
       "description": "Compressed size in bytes."
      },
      "percentSaved": {
       "type": "number",
       "description": "Percent reduction (can be negative)."
      }
     },
     "additionalProperties": false
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "image": "UklGRk4AAABXRUJQVlA4IEIAAAAwAQCdASo...<base64>",
  "width": 1024,
  "format": "webp",
  "height": 768,
  "inputBytes": 102400,
  "contentType": "image/webp",
  "outputBytes": 38211,
  "percentSaved": 62.7
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/agent-image-compression-api-841d02c8/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from agent-image-compress-production.up.railway.app](https://www.zero.xyz/host/agent-image-compress-production.up.railway.app/llms.txt)
