selan.ai
Security & cost

Docs · Own proxy

Your keys on your own servers

With Own proxy, Selan's proxy runs inside your network and every key stays in your own vault. Selan still picks which key a request uses, applies your limits and shows usage, but it never receives a key or connects into your network.

The idea

How does it work?

  1. A developer's request reaches your proxy, inside your VPN.
  2. Your proxy asks Selan who the developer is and which key to use. Selan answers with the key's name, for example anthropic-1, never the key.
  3. Your proxy asks selan-keys for that key, and selan-keys reads it from your vault. The vault's address is set in selan-keys, so Selan cannot point it anywhere else.
  4. Your proxy sends the request to that key's provider, at a host built into the image you run.
  5. After the answer, your proxy reports usage to Selan: who, which model, tokens and cost.

What runs where?

Caddy, the proxy, the gateway, Postgres, selan-keys, OpenBao and unseal run on your server; Selan holds each key's name, provider and status, never the key. Services has each container, the hosts the server calls and who can reach what.

What does Selan see?

Selan seesSelan never receives
Each key's name, provider and statusThe key itself, or an account's sign-in token
Usage: who, which model, tokens, cost, the status codePrompts and answers
Each of your servers' version and healthThe provider's error text

Every connection starts inside your network: your proxy calls Selan, and Selan answers. Selan never connects to anything behind your VPN.

What if Selan itself were compromised?

It could not:

  • read a key already in your vault, or send one anywhere but its provider;
  • reach your proxy, selan-keys, gateway or vault;
  • put software you did not pin on your servers or your developers' machines.

It could stop answering, so new requests wait, and it could see usage.

One exception: a key while it is being typed. You add keys in Selan's console, and the browser sends each one straight to your selan-keys. The console's code comes from Selan, so a compromised Selan could change it to catch a key at that moment. Keys already stored stay out of reach. Every addition is logged in your vault, with who added it and when.

What works on Own proxy?

  • Models: Claude and ChatGPT accounts, Anthropic API, OpenAI Platform, Google Vertex, OpenRouter, Kimi Code and Ollama. Nexos models are not offered.
  • Connectors: one that needs something only Selan holds is not offered: Selan's own sign-in apps, its Google Cloud, Google Workspace, or a secret Selan would keep. Your list of the others is LAUNCH_CONNECTORS.
  • Apps hosted by Selan, such as Hermes Agent and Paperclip, cannot be launched while Own proxy is on.
  • Reconnecting an account is not available: remove the key and add it again.

Setting it up

What do I need?

What
A serverDebian or Ubuntu with 1 GB of memory and git, inside your network. The install adds Docker if it is missing; on any other Linux, install Docker with its compose plugin first.
A VPNYour proxy, selan-keys and vault must not be reachable from the internet; developers and admins connect through it. See Which VPN?
A domainThree names inside your VPN, for example gw.example.com for the proxy, mcp.example.com for the MCP gateway and keys.example.com for selan-keys.
CertificatesThe install asks which you want: Let's Encrypt over DNS with an API token from your DNS provider (the names are private, so it can check them only that way), or certificate files you bring.
A vaultHashiCorp Vault if you have one. If not, the install brings OpenBao.
An ownerA Selan owner of your company, to add the server and switch it on. With no company yet, create one at auth.selan.ai/r; at the bottom of onboarding, Skip: I'll run Selan on my own servers goes to Add server.

Which VPN?

  • Tailscale, for a team. Turn off key expiry for the server, or it drops off after 180 days.
  • WireGuard, with no outside service. One peer per person, and UDP port 51820 open on the server.
  • Your company's own VPN, if you have one.
  • An SSH tunnel, for one person trying it. The proxy listens on 127.0.0.1 and your machine forwards port 443 to it over SSH.

The install refuses a public address and finds your VPN address on a Tailscale, WireGuard, OpenVPN, ZeroTier or Nebula interface. Point the three names at it in the DNS your people use. At the end it checks from the internet that nothing on the server answers.

How do I install it?

In Selan, open Settings › General › Own proxy, press Configure, then Add server. Copy the line it shows and run it on your server, inside your VPN. It carries your registration token and the release Selan has tested:

export SELAN_REGISTRATION_TOKEN=selanreg_…
{ [ -d /opt/selan ] || sudo git clone --depth 1 --branch <tag> \
    https://github.com/selan-ai/selan-self-hosted /opt/selan; } &&
  sudo git -C /opt/selan fetch -q --depth 1 origin tag <tag> &&
  sudo git -C /opt/selan checkout -q <tag> &&
  sudo --preserve-env=SELAN_REGISTRATION_TOKEN /opt/selan/install.sh

It clones the public repository selan-self-hosted into /opt/selan at that tag, or moves an existing /opt/selan to it. Then install.sh asks for anything you did not set (the names, the VPN address, the certificates, the vault), checks each image's signature and digest, writes /opt/selan/.env, starts everything, and waits until your server answers.

With OpenBao, the install writes its unseal key and root token to /opt/selan/openbao-init.json. Copy that file off the server and keep it safe: without it nobody can unseal the vault, and with it anybody can read every key.

LAUNCH_CONNECTORS in /opt/selan/.env allowlists the connectors Selan may hand your developers' apps. install.sh fills it with the connectors your own gateway serves; a connector on any other host needs its URL added there.

The token is shown once. It reaches the script through the environment, not the command line, where any user on the machine could read it from ps.

Let an agent do it

Two Claude Code skills do the install with you. They show you the release, compose.yaml and install.sh first, and you run Add server's line yourself, so Claude never sees a token or a key.

SkillWhat it does
self-host-serverInstalls on a Debian or Ubuntu host over SSH: VPN (Tailscale, WireGuard or an SSH tunnel), DNS, certificates, moving your keys, switching Own proxy on, and later upgrades and removal.
self-host-localRuns the same stack on this machine with Docker, to try it.

Add them as a plugin, with these two lines inside Claude Code:

/plugin marketplace add selan-ai/selan-self-hosted
/plugin install selan-self-hosted@selan-self-hosted

Or put both folders in ~/.claude/skills; take both, since the local skill reads the server one. A link follows the clone, so git pull updates them; to copy instead, use cp -R in place of ln -s.

git clone https://github.com/selan-ai/selan-self-hosted ~/selan-self-hosted
mkdir -p ~/.claude/skills
ln -s ~/selan-self-hosted/skills/self-host-server ~/.claude/skills/self-host-server
ln -s ~/selan-self-hosted/skills/self-host-local ~/.claude/skills/self-host-local

Then ask Claude, for example "install Selan's Own proxy on my VPS".

How do I switch it on?

  1. In Selan, open Settings › General › Own proxy and press Configure. Each part appears there once it calls in.
  2. Run sudo selan-keys import on your server to move the keys Selan still holds. For ten minutes Selan hands each one over, sealed to that server, and deletes its copy; the command prints each key as it is stored. On a release before v0.2.5 the command is sudo docker compose --project-directory /opt/selan exec -T keys selan-keys import. Then change them at the provider, since Selan held them. Disconnect Google Workspace first, and remove a Google Vertex connection and add it again with your own service account.
  3. When every part shows Healthy and no key is left on Selan, turn on Use my own proxy.
  4. Add new keys under Tokens › Add token, from a browser on your VPN, and invite people under Members › Invite by email. Each developer installs the selan CLI and runs selan login into your company.

How do I upgrade?

Each release is a tag of selan-self-hosted. To move to the one Selan names, press Add server again and run the new line. It moves /opt/selan to that tag and runs install.sh with the saved settings; registered parts ignore the new token.

To pick a tag yourself, see what changes, then move to it:

sudo git -C /opt/selan fetch --depth 1 origin tag <new tag>
sudo git -C /opt/selan diff HEAD <new tag>
sudo git -C /opt/selan -c advice.detachedHead=false checkout <new tag> &&
  sudo /opt/selan/install.sh

Going back is the same with the old tag. Every upgrade runs code from the tag you choose, so read it first. Settings › General › Own proxy shows each part's version and says Update needed when one is older than Selan supports.

Using it

How do I add a key?

Open Tokens › Add token in Selan's console, connected to your VPN. The browser sends the key, with a single-use ticket from Selan, straight to selan-keys, which checks it with the provider, stores it in your vault and tells Selan only its name. It never replaces a key that already has that name. Off the VPN, Add token says so. Claude, ChatGPT and Kimi Code accounts connect the same way, and their sign-in tokens go to your vault.

Do developers change anything?

Almost nothing. On your VPN, developers run selan login into the company, then selan claude or selan codex; each reaches your proxy by itself.

How do I use the API?

Your proxy answers the same API as Selan's gateway, at your own name, from a machine on your VPN. Make a company API token under Settings › API tokens and send it as Authorization: Bearer. The rest is on the API page.

PathFor
POST /anthropic/v1/messagesAnthropic-shaped clients: the Messages API
POST /openai/v1/responsesOpenAI-shaped clients: the Responses API
GET /anthropic/v1/models, GET /openai/v1/modelsThe models your company may use

Use an id that /anthropic/v1/models lists. A Claude model has its bare id, such as claude-haiku-5-5. Another provider's model is claude-selan-<provider>-<model>, such as claude-selan-openai-gpt-6-2-sol for GPT 6.2 Sol on a ChatGPT account. Names such as openai:gpt-6.2-sol, as on the API page, work too.

export SELAN_TOKEN=selanct_...
curl https://gw.example.com/anthropic/v1/messages \
  -H "Authorization: Bearer $SELAN_TOKEN" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{"model": "claude-haiku-5-5", "max_tokens": 256, "stream": true,
       "messages": [{"role": "user", "content": "Reply with ok"}]}'
curl https://gw.example.com/openai/v1/responses \
  -H "Authorization: Bearer $SELAN_TOKEN" \
  -H "content-type: application/json" \
  -d '{"model": "claude-selan-openai-gpt-6-2-sol", "stream": true,
       "input": "Reply with ok"}'

Always send "stream": true to /openai/v1/responses: a model on a ChatGPT account answers only a stream, and one Selan reaches through a translation refuses anything else with stream_required.

Claude Code takes the same base URL and token:

export ANTHROPIC_BASE_URL=https://gw.example.com/anthropic
export ANTHROPIC_AUTH_TOKEN=$SELAN_TOKEN
claude

The Claude Agent SDK works as on the Claude Agent SDK page, with your own base URL, and the same model ids:

ANTHROPIC_BASE_URL=https://gw.example.com/anthropic

The OpenAI Agents SDK takes a client pointed at https://gw.example.com/openai/v1, with the token as its key, and a model that /openai/v1/models lists. Tracing is off, so nothing is sent to api.openai.com.

import OpenAI from "openai"
import {
  Agent,
  run,
  setDefaultOpenAIClient,
  setOpenAIAPI,
  setTracingDisabled,
} from "@openai/agents"

setDefaultOpenAIClient(new OpenAI({
  baseURL: "https://gw.example.com/openai/v1",
  apiKey: process.env.SELAN_TOKEN,
}))
setOpenAIAPI("responses")
setTracingDisabled(true)

const agent = new Agent({
  name: "Assistant",
  instructions: "Reply with ok",
  model: "gpt-6.2-sol",
})
const result = await run(agent, "Hello", { stream: true })
await result.completed
console.log(result.finalOutput)
import asyncio
import os
from openai import AsyncOpenAI
from agents import (
    Agent,
    Runner,
    set_default_openai_api,
    set_default_openai_client,
    set_tracing_disabled,
)

set_default_openai_client(AsyncOpenAI(
    base_url="https://gw.example.com/openai/v1",
    api_key=os.environ["SELAN_TOKEN"],
))
set_default_openai_api("responses")
set_tracing_disabled(True)

async def main():
    agent = Agent(
        name="Assistant",
        instructions="Reply with ok",
        model="gpt-6.2-sol",
    )
    result = Runner.run_streamed(agent, "Hello")
    async for _ in result.stream_events():
        pass
    print(result.final_output)

asyncio.run(main())

Codex takes a provider in ~/.codex/config.toml, with the token in SELAN_TOKEN:

model_provider = "selan"

[model_providers.selan]
name = "Selan"
base_url = "https://gw.example.com/openai/v1"
wire_api = "responses"
env_key = "SELAN_TOKEN"

How do I know it is working?

Your proxy and selan-keys call Selan every minute with their version, and selan-keys says whether your vault answers. Settings › General › Own proxy shows each part. A part silent for five minutes turns red and your owners get an email. Each container also answers /healthz, /readyz and /metrics for your own monitoring. Backups, disks and your VPN are yours to watch.

Reference

What does each service do?

Each image is pinned by its digest in compose.yaml at the release tag, and install.sh checks every signed image's signature against signers.txt before it pulls it. Postgres, whose publisher signs none, runs by its digest alone.

caddy

ImageCaddy 2.11.9 with the DNS provider modules, built from selan-self-hosted's caddy/Dockerfile and signed by its caddy-image workflow
What it doesTLS for the three names, and a 403 for any client outside ALLOWED_CIDRS
Called byYour VPN, on port 443 at your VPN address (127.0.0.1 with an SSH tunnel). It sends gw. to the proxy, mcp. to the gateway, and keys. to selan-keys' admin API and /readyz only
Keepscaddy-data: certificates, its ACME account and, with internal, its own CA. No backup needed with dns or files; with internal, losing it means every client trusts a new CA
If it is downNobody on the VPN reaches the proxy, the gateway or keys.: requests, connectors and Add token fail. The other parts still call Selan by themselves

proxy

Imageselan-proxy 0.1.1, signed by selan-proxy's GitLab CI at a release tag
What it doesThe endpoint Claude Code, Codex and Claude Desktop use. It asks Selan which key a request uses, reads that key from selan-keys, calls the provider and reports usage
Called byCaddy, on port 8080 inside the server; no port on the host
Keepsproxy-identity: its key pair and registration, the key that names detected secrets, and Gemini's thought signatures for a week. Back it up; lost, it registers again with a new token from Add server
If it is downDevelopers' requests fail. With Own proxy on, nothing falls back to Selan's proxy, which holds none of your keys. Selan marks it silent after five minutes

gateway

Imageselan-mcp-gateway 0.1.2, signed by selan-mcp-gateway's GitLab CI at a release tag
What it doesSelan's MCP gateway for your connectors at mcp.: Selan's own tools, Slack, GitLab, GitHub, Figma and PostgreSQL. The selan tools that reach Reactor (reactor.selan.ai) do not work on your own server yet
Called byCaddy, on port 8080 inside the server; no port on the host
Keepsgateway-identity: its key pair and registration. Back it up; lost, it registers again
If it is downConnectors on your gateway fail. Model requests carry on

postgres

ImagePostgres 18.7 from Docker Hub. Its publisher signs none, so the pinned digest is the check
What it doesThe gateway's database: its sign-ins, each naming a key in your vault rather than holding it
Called byThe gateway alone, on port 5432
Keepsgateway-db, whose password is GATEWAY_DB_PASSWORD in /opt/selan/.env. Back it up
If it is downThe gateway cannot read its sign-ins, so connectors fail. A gateway that is starting waits for it

keys

Imageselan-keys 0.1.5, signed by selan-keys' GitLab CI at a release tag
What it doesThe only part with a vault identity, an AppRole limited to kv/selan/. Serves keys to the proxy and the gateway by name, takes new keys from your admins' browsers, checks keys, lists models and renews accounts as Selan asks, and stores the keys selan-keys import moves
Called byThe proxy and the gateway on port 8080, each with its own token, and your admins' browsers through Caddy, which reaches only its admin API on port 8081 and /readyz
Keepskeys-identity: its signing and sealing key pairs and its registration. Keys Selan hands over are sealed to it. Back it up; lost, it registers again
If it is downThe proxy and the gateway cannot read keys: requests and connectors fail once their five-minute copies run out, and Add token fails

openbao

ImageOpenBao 2.7.2 from quay.io, signed by OpenBao's release workflow. It runs only when you have no Vault of your own
What it doesThe vault: it holds every key
Called byselan-keys and unseal, on port 8200
Keepsopenbao-data: every key. Back it up, with /opt/selan/openbao-init.json, which holds its unseal key and root token, both off the server
If it is downselan-keys cannot read the vault: requests fail once the five-minute copies run out, and Selan shows “It cannot read your vault.”

unseal

ImageThe same OpenBao image, running unseal-watch.sh from selan-self-hosted
What it doesOpenBao starts sealed after every restart. This unseals it with /opt/selan/openbao-unseal.key, which only root can read
Called byNobody
KeepsNothing; it reads the key file
If it is downNothing at once. After OpenBao's next restart it stays sealed until you run /opt/selan/unseal.sh

To see each one, on the server:

sudo docker compose --project-directory /opt/selan ps
sudo docker compose --project-directory /opt/selan exec openbao bao status
sudo docker compose --project-directory /opt/selan logs --since 10m keys

ps shows every container running, and Postgres healthy. bao status says Sealed false. From your VPN, https://gw.example.com/readyz checks the proxy, selan-keys and the vault, https://mcp.example.com/readyz the gateway, selan-keys and Selan, and https://keys.example.com/readyz selan-keys and the vault. Each answers 200 when all is well; the logs say why one does not.

Which hosts does the server call?

Nothing on the internet calls in: Caddy's port 443 is open on your VPN address alone (on 127.0.0.1 with an SSH tunnel), and no other container has a port on the host. Your VPN may need a port of its own, such as WireGuard's UDP 51820. Everything below is the server calling out.

WhoHostsWhen
gitgithub.comInstall and upgrade: selan-self-hosted at a tag
install.shYour distribution's package mirrors, download.docker.comInstall, on Debian or Ubuntu, only when curl or Docker is missing
Dockereurope-docker.pkg.devInstall and upgrade: the proxy, gateway, selan-keys and Caddy images and their signatures
Dockerquay.io, docker.io, ghcr.ioInstall and upgrade: OpenBao, Postgres, and cosign, which checks the signatures
cosignSigstore, under sigstore.devInstall and upgrade: the trust root the signatures are checked against
install.sh1.1.1.1, check-host.netThe check from outside at the end; SELAN_OUTSIDE_CHECK=no skips it
Proxy, gateway, selan-keyscontrol.selan.aiAlways: sessions, leases, usage, heartbeats and key work
Gatewayauth.selan.ai, reactor.selan.aiSigning out a spent session; the selan tools that reach Reactor
Proxy, selan-keysapi.anthropic.com, chatgpt.com, api.openai.com, openrouter.ai, api.nexos.ai, api.kimi.ai, ollama.comRequests (proxy); key checks and model lists (selan-keys)
Proxyaiplatform.googleapis.com, aiplatform.us.rep.googleapis.com, aiplatform.eu.rep.googleapis.comGoogle Vertex requests
selan-keysplatform.claude.com, auth.openai.com, auth.kimi.ai, oauth2.googleapis.comAccount sign-ins and renewals, and Vertex access tokens
Gatewayslack.com, gitlab.com, github.com, api.github.com, api.figma.com, your PostgreSQL hostsThe connectors it serves
selan-keysYour own VaultOnly when you use your own Vault
Caddyacme-v02.api.letsencrypt.org, your DNS provider's APIOnly with Let's Encrypt over DNS

A registry may send image layers from other hosts of its own.

Who can reach what?

WhoReachesHolds a key
The internet, Selan includedNothing on your serverSelan: each key's name, once selan-keys import has moved the keys it held
Your VPN: developers' tools, admins' browsersCaddy on port 443, and through it the proxy, the gateway and selan-keys' admin APIAn admin's browser, while a key is typed
The proxy and the gatewayselan-keys with their own tokens, Selan, the providers or the connectors' servicesA key read for a request, for up to five minutes
selan-keysThe vault, Selan, the providers' check and sign-in hostsEach key as it reads or writes it
The vault: OpenBao or yoursNothingEvery key, at rest

A key leaves the vault only through selan-keys, which sends it to its provider to check or renew it, or to the proxy or the gateway, which send it only to its provider or its connector's service.

Which endpoints does it add?

EndpointCalled byWhat it does
POST keys…/selan/keysSelan's console, in your browser, with a ticketChecks a key, stores it in your vault, registers its name with Selan
DELETE keys…/selan/keys/{key}Selan's console, with a ticketRemoves a key from your vault
POST keys…/selan/link/{provider}Selan's console, with a ticketStarts a Claude, ChatGPT or Kimi Code sign-in; its secret part stays in selan-keys
POST keys…/selan/link/{provider}/completeSelan's console, or the providerFinishes it and stores the token in your vault
GET keys…/v1/keys/{name}Your proxy and gateway, each with its own tokenReads one key from your vault
/healthz, /readyz, /metricsYour monitoringHealth and metrics

Each part calls Selan with a key pair generated on your server, whose private half never leaves it.

More