# EVF-SAM2 Segmentation

Edit and enhance images with EVF-SAM2 Segmentation from fal through one Spiral API key. It runs in the background and returns images. Pay as you go, with no subscription.

- Provider: fal
- Category: Image
- Runs: In the background
- Returns: image
- Tool id: `fal` / `fal-ai/evf-sam`
- Page: https://spiral.ai/tools/fal/fal-ai/evf-sam

## Pricing

$0.0065 per run at the default inputs.

## Limits

- Longest queue wait: 1 hour
- Run deadline: 30 minutes
- Longest run, end to end: 225 minutes
- Largest inline input: 1 MB
- Largest input file: 2 GB
- Largest output: 5 GB

## Input

| Field | Kind | Allowed | Default | Description |
| --- | --- | --- | --- | --- |
| `prompt` (required) | text |  | — | The prompt to generate segmentation from. |
| `negative_prompt` | text |  | — | Areas to exclude from segmentation (will be subtracted from prompt results) |
| `semantic_type` | true or false |  | false | Enable semantic level segmentation for body parts, background or multi objects |
| `image_url` (required) | URL or file |  | — | URL of the input image |
| `mask_only` | true or false |  | true | Output only the binary mask instead of masked image |
| `use_grounding_dino` | true or false |  | false | Use GroundingDINO instead of SAM for segmentation |
| `revert_mask` | true or false |  | false | Invert the mask (background becomes foreground and vice versa) |
| `blur_mask` | number (whole) | 0 to 50 | 0 | Apply Gaussian blur to the mask. Value determines kernel size (must be odd number) |
| `expand_mask` | number (whole) | 0 to 20 | 0 | Expand/dilate the mask by specified pixels |
| `fill_holes` | true or false |  | false | Fill holes in the mask using morphological operations |

## Example

```bash
curl https://api.spiral.ai/v1/runs \
  -H "Authorization: Bearer $SPIRAL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "provider": "fal",
    "model": "fal-ai/evf-sam",
    "input": {
      "prompt": "Cat in the middle of the image",
      "image_url": "https://storage.googleapis.com/falserverless/web-examples/evf-sam2/evfsam2-cat.png"
    }
  }'
```

Try it in the Playground: https://spiral.ai/start?provider=fal&model=fal-ai%2Fevf-sam

## Common questions

### EVF-SAM2 Segmentation

**How much does EVF-SAM2 Segmentation cost?**

$0.0065 per run at the default inputs. You pay as you go from one Spiral balance, with no subscription, and a failed run is not charged.

**How do I use EVF-SAM2 Segmentation through an API?**

Send `POST /v1/runs` with `"provider": "fal"`, `"model": "fal-ai/evf-sam"` and the input fields on this page, using one Spiral API key. It runs in the background: poll the run, or name a webhook to be told when it finishes.

**Do I need an account with fal to use EVF-SAM2 Segmentation?**

No. Spiral runs it on its own fal account and charges your Spiral balance.

**Can my AI agent use EVF-SAM2 Segmentation?**

Yes. Agents find and run it through Spiral's MCP server, CLI or agent skill, with the same API key.

