# Models

> Connect any model, cloud or local, through the bundle's inference block.

The `inference` block names the model and how Loom reaches it. Changing models is a change to the
bundle, never to code.

## Cloud APIs

```yaml
inference:
  provider: anthropic          # or openai, openrouter
  model: claude-haiku-5-5
```

The key comes from `<PROVIDER>_API_KEY` in the environment (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`,
`OPENROUTER_API_KEY`), or from a vault reference with `secret_ref: vault://<namespace>/<name>`. Keys
never go in the bundle itself.

## Local servers

Any OpenAI-compatible server works: Ollama, vLLM, llama.cpp, LM Studio. Name it anything and give
its endpoint:

```yaml
inference:
  provider: local
  model: qwen3:4b
  endpoint: http://127.0.0.1:11434/v1
  location: local
```

`location` is a declaration Loom checks at load. With `provider: local`, the endpoint must be on
loopback.

## In process on Apple silicon

```yaml
inference:
  provider: mlx
  model: "~/models/Qwen3-4B-4bit"
  location: local
```

Install the extra once with `uv sync --extra mlx`.

## Coding-agent CLIs

`claude-cli` and `codex-cli` run the `claude` or `codex` CLI as a subprocess, signed in as you, with no
API key. They can keep a session between calls with `session: keep`.

```yaml
inference:
  provider: claude-cli
  model: haiku
```

## Embedded

`provider: host` means the app embedding Loom supplies the model itself, such as Apple Foundation
Models in an iPhone app. See [Embed Loom](/loom-site/deploy/embedding/).

## Structured output

Loom always validates the model's answer against a schema. Today it asks for JSON in the prompt,
parses it and validates it, and on failure sends the errors back and asks again. That works with
every model. Validation is never skipped, whatever the model.