# image-rehoster (`nativefoundation-inc/image-rehoster`) Actor

Re-host any image at a stable, public Apify URL. Provide a URL or base64 data and get back a permanent retrieval link. Supports JPEG, PNG, WebP, GIF, AVIF, SVG, and more. Up to 50 MB per image.

- **URL**: https://apify.com/nativefoundation-inc/image-rehoster.md
- **Developed by:** [NativeFoundation, inc.](https://apify.com/nativefoundation-inc) (community)
- **Categories:** Developer tools, Automation, Other
- **Stats:** 3 total users, 2 monthly users, 40.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 image hosteds

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## Image Rehoster

Re-host any image at a stable, public Apify URL. Provide a URL or base64 data and get back a permanent retrieval link.

### What it does

Image Rehoster downloads an image from a URL (or decodes base64 input) and stores it in Apify Key-Value Store, returning a publicly accessible retrieval URL. The URL requires no authentication and works anywhere images are accepted.

### Use cases

- **Vision-model APIs** (GPT-4o, Claude, Gemini) that need a public image URL
- **Re-hosting ephemeral URLs** that expire or require auth
- **AI-agent pipelines** that pass images between steps
- **Stable links** for images behind CDNs with short-lived tokens

### Input

| Field | Type | Description |
|-------|------|-------------|
| `imageUrl` | string | Direct URL of the image to download and host (up to 50 MB) |
| `imageBase64` | string | Base64-encoded image data (alternative to imageUrl) |
| `filename` | string | Optional filename stem (extension added automatically) |
| `permanentUrl` | boolean | **Default: true** — store in a named KVS for a permanent URL |
| `storeName` | string | Named store override (default: `hosted-images`) |

Provide either `imageUrl` or `imageBase64`.

### Output

```json
{
  "key": "my-image.png",
  "retrievalUrl": "https://api.apify.com/v2/key-value-stores/<id>/records/my-image.png",
  "permanent": true,
  "size": 102400
}
````

- `retrievalUrl` — public, no-auth URL to the hosted image
- `permanent` — `true` for named-store URLs (never expires); `false` for default-store URLs (expires with plan retention)
- `size` — image size in bytes

### Permanent vs temporary URLs

By default, images are stored in a **named** Key-Value Store (`hosted-images`), giving you a permanent URL that never expires. You pay for that storage as long as it exists.

Set `permanentUrl: false` for a temporary URL that auto-deletes with your Apify plan's data-retention window (approx. 7-30 days) at no ongoing cost.

### Pricing

**Pay-per-event + usage — $0.003 per image hosted** ($3 per 1,000), **plus Apify platform usage (compute + storage) at cost**. You are charged once per image you host (the run cost is typically ~$0.0003 at 512 MB).

Retrieving the image afterwards is billed as standard Apify Key-Value Store read operations on your own account (~$0.0045 per 1,000 reads). There is **no per-GB egress charge** for serving the public URL.

### Supported formats

JPEG, PNG, WebP, GIF, AVIF, SVG, BMP, TIFF, ICO, and any other binary image format. Maximum file size: 50 MB.

# Actor input Schema

## `imageUrl` (type: `string`):

Direct URL of the image to download and host. Must resolve to a binary image file — not an HTML page, not a redirect to a login screen. HTTP and HTTPS supported. Up to 5 redirects are followed automatically. Maximum file size: 50 MB. The file extension from the URL path is preserved in storage (falls back to .png if none detected). Supported formats: JPEG, PNG, GIF, WebP, AVIF, SVG, BMP, TIFF, ICO, and any other binary image format. Provide this OR imageBase64 — never both; if both are sent, imageUrl wins. Example: 'https://example.com/assets/hero.jpg'

## `imageBase64` (type: `string`):

Base64-encoded image data, as an alternative to imageUrl — use this to send a PNG/JPEG/etc. directly without a public URL. Accepts a data URI (e.g. 'data:image/png;base64,iVBORw0...'), whose declared type sets the stored file extension, or raw base64 (stored as .png). Maximum decoded size: 50 MB. Provide this OR imageUrl — never both; if both are sent, imageUrl takes precedence and this is ignored.

## `filename` (type: `string`):

Optional filename stem for the stored image. Do NOT include a file extension — it is appended automatically (from imageUrl, or from the base64 data URI's type). If omitted, a random UUID v4 is used as the stem. Use a filename when you need a predictable, human-readable key or want to overwrite a previously stored image with the same key (within the same store). Example: 'product-hero' → stored as 'product-hero.jpg'. Spaces and unsupported characters are replaced with hyphens.

## `permanentUrl` (type: `boolean`):

ON by default: the image is stored in a NAMED Key-Value Store, so the retrieval URL is permanent and never expires (re-running with the same filename updates the same URL). TRADE-OFF: a named store is never auto-cleaned, so you (the store owner) are billed for its storage for as long as it exists, and every read of its public URLs is billed to your account with no expiry cap. Turn OFF for a temporary URL that auto-deletes with your Apify plan's data-retention window (approx. 7–30 days, depending on your plan) at no ongoing cost. NOTE: Free-plan accounts may not have publicly accessible named stores — if the actor detects this, it will fail with a clear error. Either upgrade to a paid plan or turn this OFF to use temporary URLs instead.

## `storeName` (type: `string`):

Which named Key-Value Store to write to when Permanent URL is on. Defaults to 'hosted-images'; override to group images into a different store (e.g. per client or project). Ignored when Permanent URL is off.

## Actor input object example

```json
{
  "imageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/280px-PNG_transparency_demonstration_1.png",
  "permanentUrl": true,
  "storeName": "hosted-images"
}
```

# Actor output Schema

## `key` (type: `string`):

The filename / storage key of the hosted image.

## `retrievalUrl` (type: `string`):

Public URL to fetch the image — no auth required.

## `permanent` (type: `string`):

True when stored in a named KVS (never expires). False for the run's default store (expires with plan retention).

## `size` (type: `string`):

Image file size in bytes.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "imageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/280px-PNG_transparency_demonstration_1.png"
};

// Run the Actor and wait for it to finish
const run = await client.actor("nativefoundation-inc/image-rehoster").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "imageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/280px-PNG_transparency_demonstration_1.png" }

# Run the Actor and wait for it to finish
run = client.actor("nativefoundation-inc/image-rehoster").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "imageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/280px-PNG_transparency_demonstration_1.png"
}' |
apify call nativefoundation-inc/image-rehoster --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=nativefoundation-inc/image-rehoster",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "image-rehoster",
        "description": "Re-host any image at a stable, public Apify URL. Provide a URL or base64 data and get back a permanent retrieval link. Supports JPEG, PNG, WebP, GIF, AVIF, SVG, and more. Up to 50 MB per image.",
        "version": "0.3",
        "x-build-id": "eFaq9k1PBjwYgfhI9"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/nativefoundation-inc~image-rehoster/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-nativefoundation-inc-image-rehoster",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/nativefoundation-inc~image-rehoster/runs": {
            "post": {
                "operationId": "runs-sync-nativefoundation-inc-image-rehoster",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/nativefoundation-inc~image-rehoster/run-sync": {
            "post": {
                "operationId": "run-sync-nativefoundation-inc-image-rehoster",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "imageUrl": {
                        "title": "Image URL",
                        "pattern": "^https?://.+",
                        "type": "string",
                        "description": "Direct URL of the image to download and host. Must resolve to a binary image file — not an HTML page, not a redirect to a login screen. HTTP and HTTPS supported. Up to 5 redirects are followed automatically. Maximum file size: 50 MB. The file extension from the URL path is preserved in storage (falls back to .png if none detected). Supported formats: JPEG, PNG, GIF, WebP, AVIF, SVG, BMP, TIFF, ICO, and any other binary image format. Provide this OR imageBase64 — never both; if both are sent, imageUrl wins. Example: 'https://example.com/assets/hero.jpg'"
                    },
                    "imageBase64": {
                        "title": "Image (base64)",
                        "type": "string",
                        "description": "Base64-encoded image data, as an alternative to imageUrl — use this to send a PNG/JPEG/etc. directly without a public URL. Accepts a data URI (e.g. 'data:image/png;base64,iVBORw0...'), whose declared type sets the stored file extension, or raw base64 (stored as .png). Maximum decoded size: 50 MB. Provide this OR imageUrl — never both; if both are sent, imageUrl takes precedence and this is ignored."
                    },
                    "filename": {
                        "title": "Filename (optional stem)",
                        "type": "string",
                        "description": "Optional filename stem for the stored image. Do NOT include a file extension — it is appended automatically (from imageUrl, or from the base64 data URI's type). If omitted, a random UUID v4 is used as the stem. Use a filename when you need a predictable, human-readable key or want to overwrite a previously stored image with the same key (within the same store). Example: 'product-hero' → stored as 'product-hero.jpg'. Spaces and unsupported characters are replaced with hyphens."
                    },
                    "permanentUrl": {
                        "title": "Permanent URL",
                        "type": "boolean",
                        "description": "ON by default: the image is stored in a NAMED Key-Value Store, so the retrieval URL is permanent and never expires (re-running with the same filename updates the same URL). TRADE-OFF: a named store is never auto-cleaned, so you (the store owner) are billed for its storage for as long as it exists, and every read of its public URLs is billed to your account with no expiry cap. Turn OFF for a temporary URL that auto-deletes with your Apify plan's data-retention window (approx. 7–30 days, depending on your plan) at no ongoing cost. NOTE: Free-plan accounts may not have publicly accessible named stores — if the actor detects this, it will fail with a clear error. Either upgrade to a paid plan or turn this OFF to use temporary URLs instead.",
                        "default": true
                    },
                    "storeName": {
                        "title": "Store name (for permanent URLs)",
                        "type": "string",
                        "description": "Which named Key-Value Store to write to when Permanent URL is on. Defaults to 'hosted-images'; override to group images into a different store (e.g. per client or project). Ignored when Permanent URL is off.",
                        "default": "hosted-images"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
