Getting started¶
Use this page when you want the shortest copy-paste path from install to first request.
Prerequisites¶
- one provider or upstream you want to route to
- provider credentials if that upstream needs them
- a terminal on macOS or Linux
1. Install LunarGate¶
If you prefer to build from source, you can also build the binary from the gateway/ repository and run it with the same config.yaml shown below.
2. Save a minimal config.yaml¶
Pick one provider pattern and save it as config.yaml.
Tip
If you are just validating the gateway locally, choose the provider you already have access to and ignore the rest for now. You can add more providers later without changing your client integration pattern.
providers:
ollama:
base_url: "http://127.0.0.1:11434"
timeout: 10m
timeout_mode: ttft
temperature: 1.0
top_p: 0.95
top_k: 64
routing:
routes:
- name: "default"
targets:
- provider: ollama
model: qwen3.5
Use timeout_mode: ttft for slow local Ollama models when startup can take a long time but you do not want to cut off the response after it begins streaming.
Optional: enable LunarGate observability¶
If you want the gateway to send request data to the LunarGate Dashboard on app.lunargate.ai, extend the same config with:
data_sharing:
enabled: true
share_prompts: true
share_responses: true
api_key: "${LUNARGATE_GATEWAY_API_KEY}"
Create that gateway API key in the Gateways section of app.lunargate.ai.
You do not need to set backend_url unless you want to override the gateway default.
Warning
Turning on share_prompts or share_responses changes the privacy boundary of your deployment. Keep them off unless you explicitly want request inspection in the LunarGate Dashboard on app.lunargate.ai.
Optional: require inbound API keys¶
If you want the gateway itself to require API keys on /v1/*, add:
security:
enabled: true
provider: "api_key"
api_key:
keys:
- name: "local-dev"
value: "${LUNARGATE_CLIENT_API_KEY}"
This minimal config already supports OpenAI-style Authorization: Bearer <key> by default.
3. Export environment variables and run¶
The gateway listens on http://127.0.0.1:8080 by default.
Small but important detail:
- your app still talks to an OpenAI-compatible API
- the main client change is usually just
base_url - the gateway config is where provider choice and routing policy live
4. Smoke test the gateway¶
curl http://127.0.0.1:8080/health
curl http://127.0.0.1:8080/v1/models
curl http://127.0.0.1:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-5.2",
"messages": [
{"role": "user", "content": "Give me one sentence about LunarGate."}
]
}'
If security.provider: api_key is enabled, include your client key:
curl http://127.0.0.1:8080/v1/models \
-H "Authorization: Bearer ${LUNARGATE_CLIENT_API_KEY}"
curl http://127.0.0.1:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${LUNARGATE_CLIENT_API_KEY}" \
-d '{
"model": "openai/gpt-5.2",
"messages": [
{"role": "user", "content": "Give me one sentence about LunarGate."}
]
}'
If your config includes an embeddings-capable model, you can also smoke test:
curl http://127.0.0.1:8080/v1/embeddings \
-H "Content-Type: application/json" \
-d '{
"model": "ollama/nomic-embed-text-v2-moe",
"input": [
"LunarGate can proxy embeddings.",
"Embeddings are useful for retrieval."
]
}'
The fastest embeddings-friendly starting points today are:
- OpenAI-compatible hosted providers that expose
/v1/embeddings - local Ollama with a model like
nomic-embed-text-v2-moe
5. Use a normal OpenAI client¶
from openai import OpenAI
client = OpenAI(
api_key="your-gateway-client-key-or-not-needed-if-auth-is-off",
base_url="http://127.0.0.1:8080/v1",
)
resp = client.chat.completions.create(
model="openai/gpt-5.2",
messages=[{"role": "user", "content": "Say hello from LunarGate"}],
)
print(resp.choices[0].message.content)
What to do next¶
- Go to Examples if you want a runnable Python, Node, Streamlit, or Docker Compose app.
- Use Python Ollama embeddings with Poetry if you want the smallest
/v1/embeddingssmoke test. - Read
lunargate/autoand autorouting if you want the gateway to choose model tiers for you. - Keep the configuration overview and detailed config pages open while editing YAML.