# Gateway Mode

When running agents in isolated sandboxes for higher security, you can use gateway mode to extend the isolation to Latchkey itself. Run this to start a Latchkey server on the machine where your main configuration lives:

```bash
# Listens on localhost:1989 by default.
# You can override this using the LATCHKEY_GATEWAY_LISTEN_HOST
# and LATCHKEY_GATEWAY_LISTEN_PORT environment variables.
latchkey gateway
```

Suppose you run an agent inside a container on the same machine, with the gateway port mapped into the container. Then setting `LATCHKEY_GATEWAY=http://localhost:1989` in your container will route your agent's `latchkey` calls to the host Latchkey (limited to a selected safe subset of commands). That way the agent won't be able to tamper with your Latchkey configuration while still being able to use Latchkey itself as intended.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.imbue.com/latchkey/basics/gateway.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
