Deploy Magpie AI Gateway
Magpie AI gateway + Web UI, one HTTPS domain and persistent storage
magpie
Just deployed
/config
Deploy and Host Magpie AI Gateway on Railway
Deploy Magpie on Railway to manage your AI model providers and serve them through a shared API endpoint. Configure providers, accounts and routing groups in the Web UI, then connect your AI tools and applications to the gateway.
About Hosting Magpie AI Gateway
The template runs the official ghcr.io/yetone/magpie:latest image directly, with persistent storage at /config and an automatically generated management key. Magpie's Web listener serves the management UI and model API on one HTTPS domain.
Magpie supports OpenAI, Anthropic and Gemini API formats, including streaming responses. Available models depend on the providers and accounts you configure.
Common Use Cases
- Connect multiple AI tools to a shared model gateway.
- Manage provider credentials and routing groups in one place.
- Give applications a compatible API endpoint for different model providers.
- Use a cloud-hosted Magpie gateway from a local Magpie installation.
Dependencies for Magpie AI Gateway Hosting
- A Railway workspace to deploy the service and persistent Volume.
- Your own model-provider credentials or subscription account.
- An AI client that accepts a configurable Base URL and API key.
Getting started
1. Deploy the template
Deploy the template to your Railway workspace and wait for the service to become Online.
The template configures the service, public HTTPS endpoint and persistent Volume automatically. It uses this start command and public target port 3430:
/magpie web --addr 0.0.0.0:3430 --no-open --gateway
Leave Railway's HTTP Healthcheck Path empty. The management page requires authentication, so an unauthenticated request to / returns 401.
2. Open the Web UI
Open the service’s Variables tab in Railway and copy MAGPIE_WEB_KEY.
Find the generated domain under Networking, then open:
https://YOUR-DOMAIN/?k=YOUR-WEB-KEY
Replace YOUR-DOMAIN with your Railway domain and YOUR-WEB-KEY with the value of MAGPIE_WEB_KEY.
Magpie exchanges the key for a browser session cookie. Keep this key private: it grants access to the management interface.
3. Add a model provider
In Providers, add a provider and enter its credentials. Select the models you want to use.
The provider’s endpoint must be reachable from Railway. For a local model server, configure an address that the Railway service can access.
4. Create a Gateway Key
Open Gateway → Gateway keys and create a key for your client.
Use this Gateway Key as the client’s API key. MAGPIE_WEB_KEY is for management access; model API requests use Gateway Keys.
5. Connect your client
Configure your client with the appropriate Base URL:
| Client API | Base URL |
|---|---|
| OpenAI-compatible | https://YOUR-DOMAIN/v1 |
| Anthropic-compatible | https://YOUR-DOMAIN |
| Gemini-compatible | https://YOUR-DOMAIN, with requests targeting /v1beta beneath this base |
Use a model ID listed by your gateway, such as provider/model, or a configured routing group.
For an OpenAI-compatible client:
Base URL: https://YOUR-DOMAIN/v1
API key: YOUR-GATEWAY-KEY
Model: YOUR-PROVIDER/YOUR-MODEL
You can also add the deployment as a Remote Magpie provider in your local Magpie installation. Use https://YOUR-DOMAIN as the address and supply a Gateway Key.
Subscription accounts
Subscription providers require their own sign-in through Magpie.
Some OAuth flows redirect your browser to a localhost callback address. For these flows, copy the complete callback URL from your browser and paste it into Magpie’s callback field.
Claude subscriptions require installing Claude Code through Magpie’s supported installation flow. Availability depends on each provider’s authentication requirements.
Persistent storage
The template mounts a Railway Volume at /config. It retains:
- Provider settings and credentials.
- Gateway Keys and routing groups.
- Saved account sign-ins.
- Plugins and caches.
- Usage records.
Keep the service at one replica. Back up the Volume before upgrading or making major configuration changes. Deployments with an attached Volume may briefly interrupt service.
Moving from the old template
The old template used a Go proxy and /gateway prefix. The current template deploys the official image directly. Update OpenAI clients from /gateway/v1 to /v1, and Anthropic, Gemini and Remote Magpie clients from /gateway to the domain root.
For an existing project, change its service source to the official image, use the start command and port above, and clear the old /healthz HTTP healthcheck. Keep its /config Volume and MAGPIE_WEB_KEY. Template edits affect future deployments; existing projects need their own settings updated.
Updates
The template uses the official latest image tag, which can change as upstream publishes new images. Using this tag alone does not enable automatic updates.
When Railway detects a new image, use the update button in the service's Source settings to deploy the new latest digest. Keep the existing /config Volume attached to preserve your configuration. Use image-based updates: an in-app binary update is replaced by the selected image on the next deployment.
Costs
Railway charges for the service’s resource usage and persistent storage. Model providers may charge separately or require a subscription.
The template does not include model-provider credentials or inference credits. Add your own provider credentials after deployment.
Verification
Magpie 0.1.2908 was tested in a fresh Railway project on 2026-11-04 for startup, management login, Gateway Key authentication, same-origin API access, cross-origin rejection and persistence of the Gateway Key and management session across redeployment.
These results apply to 0.1.2908; they do not verify future images published under latest. The running Web UI reported v0.1.2908. No provider credentials were supplied; real model responses, SSE and subscription sign-in were not tested in this run. The verification project used the template's settings, configured directly rather than through a second one-click template deployment. The temporary verification project was deleted after these checks.
Why Deploy Magpie AI Gateway on Railway?
Railway hosts the gateway and its persistent configuration behind one HTTPS domain.
Links
Template Content

