# Sam 3

> SAM 3D enables full scene reconstructions, placing objects and humans in a shared context together.


## Overview

- **Endpoint**: `https://fal.run/fal-ai/sam-3/3d-align`
- **Model ID**: `fal-ai/sam-3/3d-align`
- **Category**: 3d-to-3d
- **Kind**: inference
**Tags**: align, 3D, 



## Pricing

Your request will cost $0.02 per unit.

For more details, see [fal.ai pricing](https://fal.ai/pricing).

## API Information

This model can be used via our HTTP API or more conveniently via our client libraries.
See the input and output schema below, as well as the usage examples.


### Input Schema

The API accepts the following input parameters:


- **`image_url`** (`string`, _required_):
  URL of the original image used for MoGe depth estimation

- **`body_mesh_url`** (`string`, _required_):
  URL of the SAM-3D Body mesh file (.ply or .glb) to align

- **`body_mask_url`** (`string`, _optional_):
  URL of the human mask image. If not provided, uses full image.

- **`object_mesh_url`** (`string`, _optional_):
  Optional URL of SAM-3D Object mesh (.glb) to create combined scene

- **`focal_length`** (`float`, _optional_):
  Focal length from SAM-3D Body metadata. If not provided, estimated from MoGe.



**Required Parameters Example**:

```json
{
  "image_url": "",
  "body_mesh_url": ""
}
```


### Output Schema

The API returns the following output format:

- **`body_mesh_ply`** (`File`, _required_):
  Aligned body mesh in PLY format

- **`model_glb`** (`File`, _required_):
  Aligned body mesh in GLB format (for 3D preview)

- **`visualization`** (`File`, _required_):
  Visualization of aligned mesh overlaid on input image

- **`metadata`** (`SAM3DBodyAlignmentInfo`, _required_):
  Alignment info (scale, translation, etc.)

- **`scene_glb`** (`File`, _optional_):
  Combined scene with body + object meshes in GLB format (only when object_mesh_url provided)



**Example Response**:

```json
{
  "body_mesh_ply": {
    "url": "",
    "content_type": "image/png",
    "file_name": "z9RV14K95DvU.png",
    "file_size": 4404019
  },
  "model_glb": {
    "url": "",
    "content_type": "image/png",
    "file_name": "z9RV14K95DvU.png",
    "file_size": 4404019
  },
  "visualization": {
    "url": "",
    "content_type": "image/png",
    "file_name": "z9RV14K95DvU.png",
    "file_size": 4404019
  },
  "metadata": {}
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/fal-ai/sam-3/3d-align \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "image_url": "",
     "body_mesh_url": ""
   }'
```

### Python

Ensure you have the Python client installed:

```bash
pip install fal-client
```

Then use the API client to make requests:

```python
import fal_client

def on_queue_update(update):
    if isinstance(update, fal_client.InProgress):
        for log in update.logs:
           print(log["message"])

result = fal_client.subscribe(
    "fal-ai/sam-3/3d-align",
    arguments={
        "image_url": "",
        "body_mesh_url": ""
    },
    with_logs=True,
    on_queue_update=on_queue_update,
)
print(result)
```

### JavaScript

Ensure you have the JavaScript client installed:

```bash
npm install --save @fal-ai/client
```

Then use the API client to make requests:

```javascript
import { fal } from "@fal-ai/client";

const result = await fal.subscribe("fal-ai/sam-3/3d-align", {
  input: {
    image_url: "",
    body_mesh_url: ""
  },
  logs: true,
  onQueueUpdate: (update) => {
    if (update.status === "IN_PROGRESS") {
      update.logs.map((log) => log.message).forEach(console.log);
    }
  },
});
console.log(result.data);
console.log(result.requestId);
```


## Additional Resources

### Documentation

- [Model Playground](https://fal.ai/models/fal-ai/sam-3/3d-align)
- [API Documentation](https://fal.ai/models/fal-ai/sam-3/3d-align/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/sam-3/3d-align)

### fal.ai Platform

- [Platform Documentation](https://docs.fal.ai)
- [Python Client](https://docs.fal.ai/clients/python)
- [JavaScript Client](https://docs.fal.ai/clients/javascript)
