# AI Background Remover - Magic Hour (`magichour/ai-background-remover`) Actor

Remove or replace an image background with precise edges.

- **URL**: https://apify.com/magichour/ai-background-remover.md
- **Developed by:** [Magic Hour AI](https://apify.com/magichour) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
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.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## 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.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## AI Background Remover - Magic Hour

Remove or replace an image background with precise edges.

### Quick start

1. Paste your **Magic Hour API key** (create one at https://magichour.ai/developer?tab=api-keys). Generations bill that account.
2. Add your image.
3. Run it. A working example is prefilled for the media fields.
4. Download the output from the results table.

### Input

| Field | Required | What it is |
|---|---|---|
| `magicHourApiKey` | yes | Your Magic Hour API key. Generations bill this account. |
| `imageUrl` | yes | The image to use. Upload a file or paste a URL. |

### Output

One row per generation:

```json
{
  "schemaVersion": "1.0",
  "externalId": "sku-4471",
  "status": "succeeded",
  "operation": "image-background-remover",
  "outputUrl": "https://...",
  "mediaType": "video/mp4",
  "processingTimeMs": 181371
}
```

`externalId` comes back exactly as you sent it, so a batch of results joins
straight back to your own catalog.

### Batch and automation

Process many items in one run three ways: a single item, a JSON array in
**Batch**, or an existing Apify Dataset via **Input dataset** — common column
names like `imageUrl`, `sku` and `prompt` are detected automatically, and
**Field mapping** handles the rest.

Use **Max items**, **Max spend** and **Concurrency** to bound a run.

Works through Apify Console, the API, MCP, n8n, Make and Zapier.

### Limitations

- Generation time depends on the model and output length; long video takes minutes.
- Output media is copied into Apify storage. Magic Hour's own download links expire.

### Support

- Bugs and feature requests: the Issues tab of this Actor.
- Questions about the models or your account: support@magichour.ai
- Docs: https://docs.magichour.ai

# Actor input Schema

## `magicHourApiKey` (type: `string`):

Required for a real generation. Create a key at https://magichour.ai/developer?tab=api-keys — usage bills that account. Leave empty only to see the Actor's setup message.

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

The image to use. Upload a file or paste a URL.

## `resolution` (type: `string`):

Output resolution. Leave empty for the default.

## `aspectRatio` (type: `string`):

Output shape. Leave empty for the default.

## `modelOverride` (type: `string`):

Run a specific model instead of the default. Leave empty unless you have a reason.

## `externalId` (type: `string`):

Returned unchanged in the output, so you can join results back to your own records.

## `batch` (type: `array`):

Process many items in one run. Each entry accepts the same fields as above.

## `inputDatasetId` (type: `string`):

Process every row of an existing Apify dataset. Common column names are detected automatically.

## `fieldMapping` (type: `object`):

Map your dataset's column names onto this Actor's inputs, e.g. {"imageUrl": "photo_link"}.

## `maxItems` (type: `integer`):

Stop after this many items.

## `maxSpendUsd` (type: `string`):

Stop before exceeding this cost. Leave empty for no ceiling beyond Apify's own limit.

## `concurrency` (type: `integer`):

How many generations to run at once.

## Actor input object example

```json
{
  "imageUrl": "https://images.pexels.com/photos/774909/pexels-photo-774909.jpeg?w=800",
  "maxItems": 100,
  "concurrency": 3
}
```

# Actor output Schema

## `results` (type: `string`):

One row per generation: your reference id, status, output URL, model and timing.

## `media` (type: `string`):

The generated media for each successful item.

# 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://images.pexels.com/photos/774909/pexels-photo-774909.jpeg?w=800"
};

// Run the Actor and wait for it to finish
const run = await client.actor("magichour/ai-background-remover").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://images.pexels.com/photos/774909/pexels-photo-774909.jpeg?w=800" }

# Run the Actor and wait for it to finish
run = client.actor("magichour/ai-background-remover").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).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://images.pexels.com/photos/774909/pexels-photo-774909.jpeg?w=800"
}' |
apify call magichour/ai-background-remover --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,magichour/ai-background-remover"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/UR4s4aPjV4tsoSbvF/builds/SlOZQa4Xow9yKeLo0/openapi.json
