# Bagel

> Bagel is a 7B parameter multimodal model from Bytedance-Seed that can generate both text and images.


## Overview

- **Endpoint**: `https://fal.run/fal-ai/bagel/understand`
- **Model ID**: `fal-ai/bagel/understand`
- **Category**: image-to-json
- **Kind**: inference
**Tags**: image-to-text, vlm



## Pricing

- **Price**: $0.05 per requests

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_):
  The image for the query.
  - Examples: "https://storage.googleapis.com/falserverless/bagel/wRhCPSyiKTiLnnWvUpGIl.jpeg"

- **`prompt`** (`string`, _required_):
  The prompt to query the image with.
  - Examples: "What is shown in the image? "

- **`seed`** (`integer`, _optional_):
  The seed to use for the generation.



**Required Parameters Example**:

```json
{
  "image_url": "https://storage.googleapis.com/falserverless/bagel/wRhCPSyiKTiLnnWvUpGIl.jpeg",
  "prompt": "What is shown in the image? "
}
```


### Output Schema

The API returns the following output format:

- **`text`** (`string`, _required_):
  The answer to the query.

- **`seed`** (`integer`, _required_):
  The seed used for the generation.

- **`prompt`** (`string`, _required_):
  The query used for the generation.

- **`timings`** (`Timings`, _required_):
  The timings of the generation.



**Example Response**:

```json
{
  "text": "",
  "prompt": ""
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/fal-ai/bagel/understand \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "image_url": "https://storage.googleapis.com/falserverless/bagel/wRhCPSyiKTiLnnWvUpGIl.jpeg",
     "prompt": "What is shown in the image? "
   }'
```

### 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/bagel/understand",
    arguments={
        "image_url": "https://storage.googleapis.com/falserverless/bagel/wRhCPSyiKTiLnnWvUpGIl.jpeg",
        "prompt": "What is shown in the image? "
    },
    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/bagel/understand", {
  input: {
    image_url: "https://storage.googleapis.com/falserverless/bagel/wRhCPSyiKTiLnnWvUpGIl.jpeg",
    prompt: "What is shown in the image? "
  },
  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/bagel/understand)
- [API Documentation](https://fal.ai/models/fal-ai/bagel/understand/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/bagel/understand)

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