BYOK (Bring Your Own Key) is the core mechanism of self-hosting: the key lives only in api/.env on your machine and is used solely for outbound calls to the gateway you chose — it never passes through any middleman server.
Choosing a gateway
There is no wrong answer — they all speak the same OpenAI protocol. OpenRouter suits international users (one key, 100+ models, free tier available); Groq has the fastest inference and a generous free quota; DeepSeek is the cheapest paid option with strong Chinese; Together offers open-weight large models; official OpenAI suits those who already hold a key; Ollama is fully local and offline with zero API cost (8 GB+ VRAM recommended — models around llama3.1:8b / qwen2.5:7b for a usable experience). Unsure? Start with a free tier — switching later is a two-line env change.
Connect and switch
Fill three lines in api/.env: DEEPSEEK_API_KEY (the generic gateway-key slot — historical name), OPENAI_BASE_URL and AI_MODEL. Switching gateways = stop → change these three lines → restart. Chat history and the AI residents' relationship data are model-agnostic — upgrading from a free 8B model to a flagship model loses not a single message.
The world owner's personal key
Besides the instance default gateway, the world owner can configure their own API key and optional base URL in the app's personal settings: once set, only the world owner's requests use that key; clearing it falls back to the instance default immediately. The key is stored server-side as encrypted ciphertext only (the encryption key is env's USER_API_KEY_ENCRYPTION_SECRET), and no read endpoint ever returns the plaintext.
What happens when the quota runs out
Gateway errors are surfaced honestly: AI residents will say something like "my mind is a bit stuck right now" instead of crashing. Top up the gateway or switch to another one, restart, and everything resumes.
Vision and media
For the AI to read images, AI_MODEL must be a model that supports image input (e.g. gpt-4o-mini, the claude family, qwen-vl-plus). Video channel / music generation use the optional MiniMax key, fully independent of the chat gateway — leaving it unset affects nothing else.
Related questions
Which large language models does Enclave support?
Enclave's model layer is fully swappable: OpenAI, Anthropic, Google, DeepSeek, and local Ollama / vLLM can all be configured. Different characters can even use different models, freely allocated by scenario and cost.Can Enclave run completely offline?
Yes. Once you swap the model layer for local Ollama / vLLM and turn off real-world sync, the entire system no longer sends any outbound requests and runs fully offline on your own machine — the strongest privacy guarantee, because it depends on no promises at all.Is my conversation data safe? Will it be used for training?
In self-hosted mode, your conversations live only on your own drive — they never leave your machine and are never used by any third party for training. The model layer can connect to cloud APIs like OpenAI and Anthropic, or be swapped for local Ollama / vLLM to run fully offline; you decide which kind of conversation goes to which model.Is Enclave free? How does pricing work?
Enclave is free to start: open it in your browser, no credit card needed. Everyday use is covered by a membership subscription; a few heavy actions (such as generating PPT / video) are billed via a pay-as-you-go wallet. The code itself is MIT open source, so self-hosting is completely free — you only pay your own model API costs.