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

# Goose

> Connect Goose to Prem API through the local Confidential Proxy.

Goose has a built-in OpenAI provider that accepts a custom host and Chat Completions path. Point it at Prem's local Confidential Proxy and select a Prem model ID.

> [!WARNING]
>
> Goose and its extensions run on your machine. Prem protects supported model traffic after the local proxy encrypts it. File, shell, browser, MCP, and extension execution remain outside the Prem confidential runtime.

> [tab] Confidential API
>
> Use the local Confidential Proxy for sensitive model traffic. [Go to the confidential setup](#confidential-api-setup).

> [tab] ZDR
>
> Use Zero Data Retention (ZDR) for OpenAI-compatible inference with non-sensitive data. [Go to the ZDR setup](#zdr-setup).

## Confidential API setup

This path uses the local Confidential Proxy to encrypt your prompts end-to-end before they leave your machine.

## How the connection works

```mermaid theme={"system"}
flowchart TB
    subgraph Local["Your machine: plaintext is available"]
        O["Goose"] -->|"OpenAI Chat Completions"| P["Confidential Proxy<br/>127.0.0.1:8787/v1"]
        T["Built-in tools and MCP extensions"] <--> O
    end

    P -->|"Encrypt before network egress"| G["Prem API Gateway<br/>ciphertext and metadata"]
    G -->|"Encrypted request"| E["Prem confidential runtime<br/>decrypt, infer, encrypt"]
    E -.->|"Encrypted response"| P
    P -.->|"OpenAI-compatible response"| O
```

## Before you start

You need:

* Goose installed. See the [official installation guide](https://goose-docs.ai/docs/getting-started/installation/).
* A Prem API key. See [API Keys](https://docs.prem.io/api-keys.md).
* A 32-byte client KEK encoded as 64 hexadecimal characters.
* The current Prem gateway and enclave endpoints.
* A chat model returned by your Prem model-list request.

Check the installed version:

```bash theme={"system"}
goose --version
```

The commands below have been exercised with Goose `1.45.0` using a normal response and a local shell-tool call.

## 1. Set your secrets

```bash theme={"system"}
export PREM_API_KEY="your-prem-api-key"
export CLIENT_KEK="your-64-character-hex-kek"
export PROXY_URL="https://gateway.prem.io"
export ENCLAVE_URL="https://conf-engine.prem.io"
```

Generate the KEK once if you do not have one:

```bash theme={"system"}
openssl rand -hex 32
```

Store both secrets outside the repository. Do not place the API key in Goose's `config.yaml`.

## 2. Start the Confidential Proxy

```bash theme={"system"}
npx -p @premai/api-sdk@1.0.70 confidential-proxy \
  --host 127.0.0.1 \
  --port 8787 \
  --compat openai \
  --kek "$CLIENT_KEK"
```

> [!WARNING]
>
> Do not use `--no-attest`. Keep attestation enabled for confidential inference.

## 3. Select an enabled model

```bash theme={"system"}
curl http://127.0.0.1:8787/v1/models \
  -H "Authorization: Bearer $PREM_API_KEY"
```

Use a returned `id`. This example uses `qwen38-27b`:

```bash theme={"system"}
curl http://127.0.0.1:8787/v1/chat/completions \
  -H "Authorization: Bearer $PREM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen38-27b",
    "messages": [{"role": "user", "content": "Reply with OK."}],
    "stream": false
  }'
```

## 4. Configure Goose

Set Goose's OpenAI provider variables in the shell that starts it:

```bash theme={"system"}
export GOOSE_PROVIDER="openai"
export GOOSE_MODEL="qwen38-27b"
export OPENAI_API_KEY="$PREM_API_KEY"
export OPENAI_HOST="http://127.0.0.1:8787"
export OPENAI_BASE_PATH="v1/chat/completions"
```

`OPENAI_HOST` contains the origin. `OPENAI_BASE_PATH` contains the Chat Completions path without a leading slash. A wrong path usually returns `404`.

Goose documents this pattern under [custom OpenAI endpoints](https://goose-docs.ai/docs/getting-started/providers/#using-custom-openai-endpoints). The API key remains in the process environment instead of `~/.config/goose/config.yaml`.

## 5. Run Goose

Run one chat-only request first:

```bash theme={"system"}
GOOSE_MODE=chat goose run \
  --no-session \
  --text "Reply with exactly OK. Do not use tools."
```

Then test a tool-capable session in a controlled workspace:

```bash theme={"system"}
GOOSE_MODE=approve goose run \
  --with-builtin developer \
  --text "Read README.md and summarize its first heading."
```

Use `approve` while evaluating commands. Goose can stream model output through the Chat Completions connection. A model-produced tool call returns through the encrypted model channel; Goose executes the tool locally.

## Tool and extension boundary

| Component | Plaintext access | Notes |
| - | - | - |
| Goose | Yes | Reads prompts, workspace files, instructions, and tool results |
| Confidential Proxy | Yes, locally | Encrypts model requests and decrypts responses |
| Prem API Gateway | No content access | Receives ciphertext and operational metadata |
| Prem confidential runtime | Yes, inside the protected runtime | Runs inference and encrypts the result |
| Built-in or MCP extension | Depends on the tool | Uses its own permissions, credentials, storage, and network path |

Limit enabled extensions, review permission mode, and run Goose from the narrowest required workspace.

## Agent limits

Each API key can run a limited number of requests at the same time, set by your [tier](https://docs.prem.io/tiers.md#concurrent-requests). The encrypted chat endpoint always streams, and each call holds a slot until its stream closes. Concurrent Goose sessions, recipes, or subagents using the same key can receive `429` responses when they exceed that limit.

Start with one session. Serialize model turns or use a separate Prem API key per concurrent worker. Do not switch to another provider if every model call must use Prem.

## Troubleshooting

> [accordion] Goose returns 404 from the provider
>
> Set `OPENAI_HOST` to `http://127.0.0.1:8787` and `OPENAI_BASE_PATH` to `v1/chat/completions`. Do not put `/v1` in both values.

> [accordion] Goose reports that no API key was passed
>
> Export `OPENAI_API_KEY="$PREM_API_KEY"` in the same process that starts Goose. Goose does not read provider API keys from `config.yaml`.

> [accordion] The API returns model not found
>
> Call `/v1/models`, then set `GOOSE_MODEL` to a returned ID.

> [accordion] The tool prompt is skipped or denied
>
> Check `GOOSE_MODE`, the enabled extension, and its permissions. Use `approve` during setup instead of bypassing tool confirmation.

> [accordion] The API returns 429
>
> Wait for active streams to finish. Reduce concurrent sessions, recipes, and subagents or use separate API keys.

## Frequently asked questions

### Does Goose need a custom provider plugin?

No. Its built-in OpenAI provider supports a custom host and Chat Completions path.

### Is Goose itself inside the Prem enclave?

No. Goose runs locally. Only supported model traffic uses the encrypted Prem path.

### Are extension calls confidential?

Not automatically. The model call is protected through Prem, but each local or remote extension has its own trust boundary.

### Can I persist these settings?

You can persist non-secret provider values in your shell or Goose configuration. Keep `OPENAI_API_KEY` in a secret manager or injected environment variable.

## ZDR setup

> [!WARNING]
>
> ZDR is not confidential. Use this path only for non-sensitive prompts,
> workspace context, and extension results.

Goose uses ZDR through its built-in OpenAI provider and a separate API key.

Confirm that `kimi-k3` appears in `GET /openai/models` for this key. Otherwise, use
an exact returned model ID. See [Models & Pricing](https://docs.prem.io/models-and-pricing.md).

```bash theme={"system"}
export PREM_API_KEY="your-api-key"
export GOOSE_PROVIDER="openai"
export GOOSE_MODEL="kimi-k3"
export OPENAI_API_KEY="$PREM_API_KEY"
export OPENAI_HOST="https://gateway.prem.io"
export OPENAI_BASE_PATH="openai/chat/completions"
```

Run a bounded request before enabling tools:

```bash theme={"system"}
GOOSE_MODE=chat goose run \
  --no-session \
  --text "Reply with exactly: zdr ok"
```

This provider does not use the local proxy or KEK. See the [ZDR overview](https://docs.prem.io/zdr/overview.md) and [Models & Pricing](https://docs.prem.io/models-and-pricing.md).

## Related

> [card] [Confidential Proxy](https://docs.prem.io/confidential-proxy.md)
>
> Review proxy modes, routes, keys, and daemon controls.

> [card] [OpenAI-compatible clients](https://docs.prem.io/guides/openai-compatible-clients.md)
>
> Understand the protocol used by Goose.

> [card] [Agents & Automation](https://docs.prem.io/agents.md)
>
> Review concurrency, retries, and unattended operation.

> [card] [Security Model](https://docs.prem.io/security-model.md)
>
> Review the protected and unprotected parts of the flow.


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