Skip to main content

Emacs with the Gateway

Use an Emacs package that lets you set an OpenAI-compatible host and endpoint. This guide uses gptel, whose backend configuration exposes the protocol, host, endpoint, API key, and model list directly.

GitHub Copilot packages use GitHub's service and authentication flow. Setting HTTP_PROXY or HTTPS_PROXY to the Keeptrusts gateway does not make that traffic OpenAI-compatible and is not supported.

Prerequisites

  • Complete Gateway Setup for IDEs, including a named gateway runtime.

  • Configure a provider target for the model you plan to use.

  • Create a client API token and export it before starting Emacs:

    export KEEPTRUSTS_IDE_TOKEN="kt_..."

The client token authenticates Emacs to the gateway. It is separate from the runtime token used by a connected gateway and from the upstream provider credential.

Configure gptel

Add a backend to your Emacs configuration:

(use-package gptel
:config
(setq gptel-backend
(gptel-make-openai "Keeptrusts"
:protocol "http"
:host "127.0.0.1:41002"
:endpoint "/v1/chat/completions"
:key (lambda () (getenv "KEEPTRUSTS_IDE_TOKEN"))
:models '(gpt-5.4-mini)
:stream t)
gptel-model 'gpt-5.4-mini))

Replace gpt-5.4-mini with the exact model identifier configured for your gateway. The entry in :models tells gptel which model names to offer; it does not create or enable an upstream target.

Restart Emacs after changing its environment, select the Keeptrusts backend, and send a prompt with the normal gptel workflow.

Verify the governed path

First confirm the client can reach the gateway:

curl -fsS \
-H "Authorization: Bearer $KEEPTRUSTS_IDE_TOKEN" \
http://127.0.0.1:41002/v1/models

Then follow events while sending a prompt from gptel:

kt events tail --since 10m --follow

A matching event proves that the request traversed Keeptrusts. If no event appears, first check gateway event delivery, the CLI organization and region, the event time window and filters, and then gptel's active backend and endpoint.

Other Emacs packages

Another package can use the same gateway only if it exposes all of these settings:

  • an OpenAI-compatible base URL or chat-completions endpoint
  • bearer-token authentication
  • an explicit model identifier
  • streaming support when the package requires it

Package-specific options change independently of Keeptrusts. Check the package's current documentation and verify the result with kt events tail; do not infer support from generic operating-system proxy settings.

Troubleshooting

SymptomCheck
Connection refusedConfirm kt gateway status and port 41002.
401 UnauthorizedConfirm Emacs inherited KEEPTRUSTS_IDE_TOKEN and that the token is active.
Model unavailableConfirm the requested model is present in GET /v1/models and in the configured provider targets.
No Keeptrusts eventRe-select the Keeptrusts backend and inspect gptel's active host and endpoint.

Next steps