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

# Microsoft Office

> Run gateway models inside Word and Excel through add-ins that take a custom endpoint, Office Scripts, and Power Automate — and why Microsoft Copilot itself can't be pointed at a gateway.

Office runs AI Reserve models today on three surfaces: **add-ins that accept a
custom OpenAI-compatible endpoint** (Word and Excel), **Office Scripts**
(Excel), and **Power Automate** (any Office data a flow can reach). All three
speak the gateway's standard OpenAI surface — every request metered and billed
on your key. Microsoft Copilot itself is the boundary: it runs exclusively on
Microsoft-managed models, and there is nothing to configure (see
[the last section](#microsoft-copilot-—-the-boundary)).

## Word and Excel — GPT for Work add-ins

[GPT for Excel](https://gptforwork.com/docs/gpt-for-excel/setup/manage-models/connect-to-api-endpoints)
and [GPT for Word](https://gptforwork.com/docs/gpt-for-word/setup/manage-models/connect-to-api-endpoints)
(Talarian's **GPT for Work** suite) are the leading Office add-ins that
connect to any OpenAI-compatible endpoint. A space owner or admin configures
the endpoint once in the
[GPT for Work dashboard](https://gptforwork.com/docs/admin/ai-configuration/manage-api-endpoints)
— **Custom API endpoints** in the sidebar — and every user in the space gets
the gateway models. Custom endpoints require their Business or Enterprise plan
or pay-as-you-go pricing.

There are two endpoint types, on separate tabs:

* **Bulk models** (Excel and Word) — the Chat Completions path, used by bulk
  prompting and the spreadsheet functions. Add an **OpenAI-compatible endpoint
  (Chat Completions API)** with:

  * **Endpoint URL**: `https://api.aireserve.com` — host root, no `/v1`
    (unlike most tools in these guides: GPT for Work appends the
    `/v1/models` and `/v1/chat/completions` resource paths itself, so a
    `/v1` suffix here would double up).
  * **API key**: your `aireserve_api_…` key.
  * **Display name** (optional): e.g. `AI Reserve` — prefixed to model names
    in the model switcher (`custom/` by default).

  Click **Check** — the add-in validates the connection — then **Save**. The
  switcher then lists the gateway's full catalog under **Connected models**
  (`/v1/models` is the discovery call — it excludes client-exclusive models
  but does include consent-gated ones, so a model your org hasn't opted into
  will list here and refuse at call time with the reason).

* **Agent models** (Excel only) — the agent sidebar, which drives the
  workbook. Add an **OpenAI-compatible endpoint (Responses API)** with the
  same Endpoint URL and key, plus a **Model ID** per entry (say
  `gpt-5.5` or `claude-sonnet-4-6`). GPT for Work requires the endpoint to
  serve `/v1/responses` over public HTTPS and the model to have at least a
  32K-token context — the gateway serves the
  [Responses format](/connect/codex) for every model, and the flagship models
  all clear the context bar.

<Note>
  **Why this just works.** GPT for Work runs inside Office's embedded browser,
  so it calls the endpoint straight from the client — which is why it requires
  public HTTPS and CORS support. The gateway has both (it answers cross-origin
  browser requests on `/v1/models`, `/v1/chat/completions`, and
  `/v1/responses`), so both endpoint types validate as-is. No proxy, no relay.
</Note>

GPT for Work covers Word and Excel only. There is no PowerPoint add-in in the
suite, and we haven't found a comparably mature PowerPoint add-in with a
custom-endpoint field — only small open-source projects. For slides, the
practical route today is drafting in Word or [chat](https://chat.aireserve.com)
and pasting across.

## Excel — Office Scripts

Office Scripts can call the gateway directly with `fetch`
([external calls are supported](https://learn.microsoft.com/en-us/office/dev/scripts/develop/external-calls)
when the script runs in the Excel application). This script reads the prompt
from `A1` and writes the answer to `B1`:

<Warning>
  Office Scripts have no secret store — the key sits in the script text, and
  anyone who can open or edit the workbook can read it. Mint a dedicated,
  spend-capped key for workbook scripts and rotate it if the file is shared.
</Warning>

```typescript theme={"dark"}
interface ChatCompletion {
  choices: { message: { content: string } }[];
}

async function main(workbook: ExcelScript.Workbook) {
  const sheet = workbook.getActiveWorksheet();
  const prompt = String(sheet.getRange("A1").getValue());

  const response = await fetch("https://api.aireserve.com/v1/chat/completions", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      Authorization: "Bearer aireserve_api_...", // your key
    },
    body: JSON.stringify({
      model: "gpt-5.4-mini",
      messages: [{ role: "user", content: prompt }],
    }),
  });

  if (!response.ok) {
    // 401/403/429/402 return an OpenAI error body — surface it instead of
    // failing later on a missing field.
    throw new Error(`Gateway error ${response.status}: ${await response.text()}`);
  }

  const completion: ChatCompletion = (await response.json()) as ChatCompletion;
  sheet.getRange("B1").setValue(completion.choices[0].message.content);
}
```

Two boundaries, both Microsoft's:
[external calls fail when a script runs through Power Automate](https://learn.microsoft.com/en-us/office/dev/scripts/develop/external-calls#external-calls-from-power-automate)
(`fetch is not defined` at runtime — use the Power Automate path below
instead), and scripts stored on SharePoint can't make external calls at all.
Tenant admins can also block external calls outright, so if the snippet fails
on a managed machine, ask IT before debugging.

## Power Automate

For flows, skip Office Scripts and call the gateway from the flow itself —
that's
[Microsoft's own guidance](https://learn.microsoft.com/en-us/office/dev/scripts/develop/external-calls#external-calls-from-power-automate).
Add an **HTTP** action:

| Field   | Value                                                                           |
| ------- | ------------------------------------------------------------------------------- |
| Method  | `POST`                                                                          |
| URI     | `https://api.aireserve.com/v1/chat/completions`                                 |
| Headers | `Authorization`: `Bearer aireserve_api_…` · `Content-Type`: `application/json`  |
| Body    | `{ "model": "gpt-5.4-mini", "messages": [{ "role": "user", "content": "…" }] }` |

Pull the reply out with the expression
`body('HTTP')?['choices']?[0]?['message']?['content']` and hand it to any
Office connector — write it to Excel rows, draft Outlook mail, fill a Word
template. HTTP actions are
[premium-class connectors in Power Automate](https://learn.microsoft.com/en-us/connectors/webcontentsv2/),
so the flow owner needs a
[Power Automate Premium license](https://learn.microsoft.com/en-us/power-platform/admin/power-automate-licensing/types).
Store the key in a secured environment variable or Azure Key Vault rather
than inline.

## Microsoft Copilot — the boundary

Microsoft 365 Copilot (now named simply **Microsoft Copilot**) cannot be
pointed at a third-party endpoint. Its models are
[chosen, hosted, and operated by Microsoft](https://learn.microsoft.com/en-us/microsoft-365/copilot/microsoft-365-copilot-application-card)
— Azure OpenAI Service, plus Anthropic and OpenAI models under Microsoft's
subprocessor arrangements — and the product has no base-URL or API-key
setting anywhere, so there is nothing to configure. A gateway can't serve a
request Copilot never sends.

Microsoft's extensibility story —
[custom engine agents](https://learn.microsoft.com/en-us/microsoft-365/copilot/extensibility/overview-custom-engine-agent)
via Copilot Studio or the Microsoft 365 Agents SDK — lets an organization
bring its own agent (and behind it, its own models) *into* the Copilot UI.
That's a build-and-host-a-bot surface, not a paste-a-key setting, and it's
out of scope for this guide.

***

Usage from these surfaces is metered per key like any other gateway traffic.
None of them carry a harness signature the gateway recognizes, so mint a
dedicated key per surface (one for the GPT for Work space, one per flow) —
that keeps Office spend cleanly separated in your analytics, and a leaked key
stays scoped to one surface.
