# Run your Agents on models from Magpie

> Connect a Magpie you run, on your Mac or at a public address, so your Agents can use its models.

Source: https://air.build/docs/team/use-models-from-magpie/

Magpie is a separate app that serves AI models through a gateway. If you run Magpie, your Agents can use its models: you connect it once in Settings › **Custom Keys**, then pick a Magpie model for any Agent.

Every field and state of the Magpie form is in [Custom Keys](https://air.build/docs/settings/custom-keys/#magpie). This page walks through the setup.

The Agents in a Team use the AI connections of the Team's owner (see [Invite people to your Team](https://air.build/docs/team/invite-people/#owner-and-member)), so set Magpie up while signed in as the owner of the Team whose Agents should use it. AirBuild doesn't check this: Magpie is saved to the account you're signed in with, and it serves the Teams you own. If you're a member of a Team, not its owner, that Team's Agents won't use it.

## Choose how AirBuild reaches Magpie

| **Connection** | Use it when | What it needs |
| --- | --- | --- |
| **Mac Bridge** | Magpie runs on your Mac. | AirBuild for Mac, on the Mac that runs Magpie. That Mac stays awake with AirBuild open, or your Agents can't reach Magpie. |
| **Direct** | Magpie runs somewhere that can be reached over HTTPS. | Its public address. A cloud Team can't reach a private network address, such as one on your home network: for a Magpie on your Mac, choose **Mac Bridge**. |

## Make a gateway key in Magpie

1. In Magpie, open **Settings › Network and sharing** and turn on **Share on local network**.
2. Open **Gateway › Gateway keys** and add a key for AirBuild. Copy it.

These are Magpie's own labels. For help with Magpie itself, the **Magpie Guide** button in AirBuild's Magpie form (under **Set Up Magpie**) opens Magpie's guide.

For **Direct**, a gateway key is optional, but Magpie's sharing has to be on either way. For **Mac Bridge**, the key is required.

## Connect Magpie in AirBuild

**Mac**

On the Mac that runs Magpie:

1. Open **Settings**, click **Custom Keys** in the sidebar, and click **Magpie** in the list of providers.
2. Under **Connection**, choose **Mac Bridge** (it's chosen already the first time). Check that **Port** is the port Magpie uses.
3. Paste the key into **Gateway Key**.
4. Click **Save**. AirBuild checks that Magpie answers and takes the key, then closes the form.

For **Direct** instead, choose **Direct**, enter Magpie's address in **URL**, paste the key if you made one, and click **Save**.

**iPhone**

On iPhone and iPad you can connect a Magpie by **Direct** only. A **Mac Bridge** is set up on the Mac that runs Magpie (see the Mac tab).

1. Open **Settings**, tap **Custom Keys** under **Connections**, and tap **Magpie** in the list of providers.
2. Under **Connection**, keep **Direct** and enter Magpie's address in **URL**.
3. Paste the key into **Gateway Key** if you made one.
4. Tap **Save**.

If you choose **Mac Bridge** here before it's set up on a Mac, the form shows what to do on the Mac, with **Get AirBuild for Mac**, and **Save** stays dimmed.

The key is saved with your account and never shown again. To replace it later, open **Magpie** and paste a new key; leave the field blank to keep the saved one.

Once Magpie is saved, its row under Custom Keys shows whether it answers. See [Custom Keys](https://air.build/docs/settings/custom-keys/#magpies-state) for each state.

## Pick a Magpie model for an Agent

Magpie's models now appear in the **Model** list, under **Magpie**:

- For one Agent, pick a Magpie model in its editor: see [Choose the model an Agent uses](https://air.build/docs/agents/choose-an-agents-model/#change-an-agents-model).
- For every Agent that has no model of its own, pick it as the **Default Model** in [Custom Keys](https://air.build/docs/settings/custom-keys/#default-model).

## Remove Magpie

Before you remove Magpie, give the Agents that use a Magpie model another model, or they stop.

1. Open Settings › **Custom Keys** › **Magpie**.
2. Tap **Remove Magpie** at the bottom left (on iPhone and iPad, the trash).
3. Confirm with **Remove**.

The question warns that Agents set to a Magpie model stop until they're given another model, and that the gateway key is deleted.

## When something goes wrong

These messages show in the form when you save a **Mac Bridge** on the Mac that runs Magpie. A **Direct** connection is saved without contacting Magpie; its row in Custom Keys then shows whether it answers.

| What you see | What to do |
| --- | --- |
| **Magpie didn't answer. Check that it's running and the address is right.** | Open Magpie, and check the **Port**. |
| **This address isn't a Magpie gateway.** | Something else answers on that port. Check that **Port** is Magpie's. |
| **Magpie only answers apps on this Mac. In Magpie, turn on Settings › Share on local network, then save again.** | Turn on **Share on local network** in Magpie, then save again. |
| **Enter a gateway key from Magpie. Your agents reach this Mac's Magpie from outside it, so Magpie asks for one.** | Make a gateway key in Magpie and paste it. |
| **Magpie didn't accept this gateway key. Check the key and that it's turned on in Magpie.** | Check the key in Magpie's **Gateway keys**, or make a new one. |
| **Magpie's model list couldn't be read. Update Magpie and try again.** | Update Magpie, then save again. |

## Questions

**An Agent on a Magpie model stopped working.**

Magpie isn't answering. With **Mac Bridge**, wake the Mac that runs Magpie and open AirBuild on it; with **Direct**, check that Magpie is running at its address. Its state in [Custom Keys](https://air.build/docs/settings/custom-keys/#magpies-state) says what's wrong. Or give the Agent another model.

**The model list says Magpie is “Offline”.**

Magpie didn't answer when the list was read. See [Choose the model an Agent uses](https://air.build/docs/agents/choose-an-agents-model/#questions).

**Do I need to keep my Mac on?**

With **Mac Bridge**, yes: the Mac that runs Magpie stays awake with AirBuild open while your Agents use it. With **Direct**, Magpie only has to be reachable at its address.
