> ## Documentation Index
> Fetch the complete documentation index at: https://docs.m-star.org/llms.txt
> Use this file to discover all available pages before exploring further.

# BAGEL

> Ask about an image, generate one from a prompt, or edit an existing image.

BAGEL can answer questions about an image, generate an image from text, or edit an existing image. All three tasks use the same checkpoint.

## Install and start

Start with the single-GPU default. To place the three guidance branches on separate GPUs, use `bagel_cfg_parallel` with `--gpus 0,1,2`. The vision encoder falls back to PyTorch SDPA when FlashAttention is unavailable.

### `bagel`

Text, image → text, image. The default `bagel_single_gpu.yaml` uses 1 GPU. The [weights](https://huggingface.co/ByteDance-Seed/BAGEL-7B-MoT) use Apache-2.0.

```bash theme={null}
uv pip install --torch-backend=auto "mstar-ai[bagel]"
mstar serve bagel
```

[Send the request](#generate-image).

### `bagel_cfg_parallel`

Text, image → text, image. The default `bagel_cfg_parallel.yaml` uses 3 GPUs. The [weights](https://huggingface.co/ByteDance-Seed/BAGEL-7B-MoT) use Apache-2.0.

```bash theme={null}
uv pip install --torch-backend=auto "mstar-ai[bagel]"
mstar serve bagel_cfg_parallel
```

[Send the request](#generate-image).

## Send a request

Run either client example in a second terminal after `/health` returns 200.

### Generate an image

Save the returned PNG.

**Python SDK**

```python theme={null}
from pathlib import Path
from mstar import MStarClient

client = MStarClient("http://localhost:8000")
image = client.generate_image("An orange cat watching snow fall.")
Path("image.png").write_bytes(image)
```

**curl**

```bash theme={null}
curl -fsS http://localhost:8000/v1/images/generations \
  -H 'Content-Type: application/json' \
  -d '{"prompt":"An orange cat watching snow fall."}' \
  | python3 -c 'import json, sys; print(json.load(sys.stdin)["data"][0]["b64_json"])' \
  | base64 --decode > image.png
```

## Deployment configs

| File | GPUs | Parallelism | When to use |
| - | - | - | - |
| `configs/bagel_single_gpu.yaml` | 1 | none | The default. |
| `configs/bagel.yaml` | 2 | encoders and VAE on GPU 0, LLM on GPU 1 | The LLM on a GPU of its own. |
| `configs/bagel_pd_disaggregated.yaml` | 2 | prefill on GPU 0, decode and image generation on GPU 1 | Prefill apart from decode. |
| `configs/bagel_cfg_parallel_2gpu.yaml` | 2 | main branch on GPU 0, both guidance branches on GPU 1 | Text-to-image with guidance on two GPUs. |
| `configs/bagel_cfg_parallel.yaml` | 3 | main branch, text guidance and image guidance each on a GPU | Guided generation and edits, one branch per GPU. |
| `configs/bagel_img_disaggregated.yaml` | 3 | prefill, decode and image generation each on a GPU | Text and image traffic apart. |
| `configs/bagel_xpu_tp2.yaml`, `configs/bagel_xpu_cfg_tp2.yaml` | 3, 7 | LLM at TP2; CFG parallel at TP2 | Intel GPUs, one request at a time; see [Intel XPU](https://docs.m-star.org/hardware.md#intel-xpu). |

A custom config that places the LLM per walk lists `image_gen_head`, `image_gen`, `image_gen_guided2` and `image_gen_guided3` on the GPU that generates images, as `configs/bagel_pd_disaggregated.yaml` does.

To use an alternative, pass `--config configs/<file>` after the launcher name. From a wheel installation, [copy the shipped YAML](https://docs.m-star.org/serving.md#custom-configs) and pass its local path.

## Settings and defaults

Request knobs go in `model_kwargs` on `/generate` and in `extra_body` on the OpenAI routes.

| Knob | Default | Effect |
| - | - | - |
| `cfg_text_scale` | 4.0 | Text guidance; 1 or less turns it off. |
| `cfg_img_scale` | 1.0; 2.0 on an edit | Image guidance; 1 or less turns it off. |
| `cfg_interval` | `[0.4, 1.0]`; `[0.0, 1.0]` on an edit | The part of the schedule guidance runs in, `[lo, hi]` within 0 to 1. |
| `cfg_renorm_type` | `global`; `text_channel` on an edit | `global`, `channel` or `text_channel`. |
| `think_mode` | `false` | The model writes its reasoning before it generates. |
| `width`, `height` | 1024 | Multiples of 16, up to 1024. On an edit they bound the output, which keeps the input's aspect. |
| `temperature`, `top_k`, `top_p`, `repetition_penalty` | 0.6, 0 (off), 1.0 (off), 1.05 | Text sampling. The checkpoint's `generation_config.json` is the backbone's chat preset, so only its `do_sample: false` is read. |

Deployment: `model_kwargs.accelerator_graph: false` serves without graph capture (default `true`). With capture on, `MSTAR_VIT_ACCELERATOR_GRAPH=1` also captures the ViT encoder.

## Limits

* Generated images are at most 1024 pixels a side.
* A `min_p` above 0 is refused.
* The chat route refuses tool calls, `n` above 1, stop sequences and OpenAI `logprobs`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.