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

# Keep a model warm

> Keep a fine-tuned model loaded between calls, so they don't wait for it to load.

A fine-tuned model answers only while it is loaded on a GPU. A loaded model is warm. When other
models need the room, it can be unloaded, and it goes cold. The next
call to a cold model waits while it loads again. That wait is a cold start, and it can take several
seconds ([cold starts](https://docs.sqwish.ai/guides/models-and-fallback.md#readiness-and-cold-starts)). Base models have no
cold starts.

Keep warm keeps a fine-tuned model loaded, so its calls never wait for a cold start. It helps most for
a model called now and then. It doesn't guarantee a latency.

This request keeps the model a family serves warm:

```bash theme={null}
curl --fail-with-body https://api.sqwish.ai/v1/families/support-router/keep-warm \
  -H "Authorization: Bearer $SQWISH_API_KEY" -H 'Content-Type: application/json' \
  -d '{"enabled": true}'
```

Send `{"enabled": false}` to switch keep warm off. The answer is the family or the model.

| Request | Keeps loaded |
| - | - |
| `POST /v1/families/{family}/keep-warm` | The model the family serves. It follows the family when the family [moves](https://docs.sqwish.ai/guides/families.md#how-a-family-moves) |
| `POST /v1/models/{family}@{number}/keep-warm` | That model, whichever model its family serves. Its own switch must be on |

* Switching a model off stops its own keep warm.
* A model kept warm through its family and on its own is one warm model. It stays warm until
  neither asks for it.

Families and models show these fields:

| Field | What it holds |
| - | - |
| `keep_warm` | Whether their own keep warm is on |
| `keep_warm_window` | The hour being billed |
| `keep_warm_stopped_at` | When keep warm switched off because the next hour couldn't be held |

## Checks

To be sure you change what you last read, add a check. If it fails, nothing changes.

* To a family, send `served`: the `adapter` of the model it serves, or `null` for none. If the
  family has moved since, you get `409 served_changed`.
* To a model, send `adapter`: its ID as you saw it. If the number names another model, you get
  `409 model_changed`.

## Limits

An account keeps at most its tier's `kept_warm` models warm at once. [Tiers](https://docs.sqwish.ai/guides/limits.md#tiers)
gives the number for each tier, and `effective_limits` on `/v1/account` gives yours. Each model
counts once, whether its family, its own switch or both keep it warm.

Each size's room for kept-warm models is shared by every account. Both limits are checked before
the model is loaded. Lowering a limit switches no model off.

A kept-warm family whose move would go over either limit waits, still kept warm, until there is
room ([what a move needs](https://docs.sqwish.ai/guides/families.md#what-a-move-needs)).

## Errors

| Error | Meaning |
| - | - |
| `409 family_empty` | The family serves no model yet |
| `409 family_off`, `409 model_off` | The family or the model is switched off. Switch it on first |
| `409 warm_limit` | You keep as many models warm as your tier allows. `details` lists them, the one used longest ago first. Each has `used_at` and the keep warms that hold it. On a tier with no keep warm, the message names the credit that unlocks it |
| `503 warm_capacity` | The size has no room for another kept-warm model. Try again in a few minutes, after `Retry-After`. The model still answers meanwhile, and loads when it's called |

## Cost

Keep warm is billed for every hour it is on, whether or not the model is called. Each hour is at
the base model's price, billed by the started minute. [Pricing](https://docs.sqwish.ai/guides/pricing.md) lists the prices.

A model is billed once, however many switches ask for it.
[Keep warm and storage](https://docs.sqwish.ai/guides/billing.md#keep-warm-and-storage) explains how each hour is held and
charged.


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