Dev mode
Dev mode is the quickest way to see everything the gateway does. One container runs the gateway and its own small database, so virtual keys, the Admin UI, spend logs and models you add from the Admin UI all work without setting up Postgres or Redis first. It comes as its own image, spanway-ai-dev, built from the same compiled release as the production images, and it needs three commands.
Dev mode is for trying the gateway on your own machine. It is not for production, for a team to share, or for anything you would be upset to lose. The limits section says why, and moving to a real deployment says what to use instead.
A real-world scenario
A developer hears that her company may put a gateway in front of its model providers and wants to see it before the platform team gets involved. She has Docker on her laptop and an Anthropic key, but no database server and no wish to learn Docker Compose this afternoon. She pulls the dev image, writes a small file with two generated secrets, and starts one container. Five minutes later she has signed in to the Admin UI, added a model, created a virtual key for a test script and watched its requests and costs show up in Logs. When the team decides to go ahead, she deletes the container and its volume, and the platform team installs the gateway with the Helm chart.
Step by step
-
Pull the dev image.
docker pull registry.spanway.ai/spanway/spanway-ai-dev:2.0.0Private preview
Spanway is in private preview. The container images and Helm charts will be published soon. To request access, write to sales@spanway.ai, and preview customers receive download instructions in their onboarding pack.
:::
-
Write a file with two generated secrets.
SPANWAY_MASTER_KEYis the admin password of the gateway andSPANWAY_SALT_KEYencrypts the provider keys it stores. Keep this file, because a new salt key makes the stored provider keys unreadable.printf 'SPANWAY_MASTER_KEY=sk-%s\nSPANWAY_SALT_KEY=sk-%s\n' "$(openssl rand -hex 32)" "$(openssl rand -hex 32)" > spanway-dev.envIn PowerShell on Windows, write the same file with:
[IO.File]::WriteAllText("$PWD/spanway-dev.env", "SPANWAY_MASTER_KEY=sk-$([guid]::NewGuid().ToString('N'))$([guid]::NewGuid().ToString('N'))`nSPANWAY_SALT_KEY=sk-$([guid]::NewGuid().ToString('N'))$([guid]::NewGuid().ToString('N'))`n")To use a provider key from the environment instead of typing it into the Admin UI, add a line such as
ANTHROPIC_API_KEY=your-provider-keyto the same file. -
Start the container. The named volume
spanway-devkeeps the database between restarts, and127.0.0.1:keeps the gateway reachable from this machine only.docker run -d --name spanway-dev -p 127.0.0.1:4000:4000 --env-file spanway-dev.env -v spanway-dev:/var/lib/spanway/dev registry.spanway.ai/spanway/spanway-ai-dev:2.0.0The first start creates the database and applies the schema, which takes about a minute.
docker logs -f spanway-devshows the progress, and the gateway is ready when the log showsUvicorn running on http://0.0.0.0:4000. -
Check that the gateway and its database are up. Read the master key from the file first, since every call below uses it.
export SPANWAY_API_KEY="$(sed -n 's/^SPANWAY_MASTER_KEY=//p' spanway-dev.env)"curl -s http://localhost:4000/health/readiness -H "Authorization: Bearer $SPANWAY_API_KEY"Expected result:
{"status":"healthy","db":"connected","airgapped":false}."db":"connected"means the built-in database is working. -
Add a model. In the Admin UI at
http://localhost:4000/ui, sign in asadminwith the master key as the password, open Models + Endpoints, pick the Add Model tab, choose Anthropic as the Provider, pickclaude-sonnet-5-5under Spanway Model Name(s), paste your provider key and click Add Model. From the command line:curl -X POST http://localhost:4000/model/new \-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \-d '{"model_name": "claude-sonnet-5-5", "spanway_params": {"model": "anthropic/claude-sonnet-5-5", "api_key": "os.environ/ANTHROPIC_API_KEY"}}'No provider account yet? Add a model that answers with fixed text instead, which is also how the image is tested:
curl -X POST http://localhost:4000/model/new \-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \-d '{"model_name": "dev-mock", "spanway_params": {"model": "openai/dev-mock", "api_key": "unused", "mock_response": "Hello from the mocked provider."}}' -
Send a chat request.
curl http://localhost:4000/v1/chat/completions \-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \-d '{"model": "claude-sonnet-5-5", "messages": [{"role": "user", "content": "Say hello in one line."}]}'Expected result: an OpenAI-format chat completion. With the
dev-mockmodel,choices[0].message.contentisHello from the mocked provider. -
Create a virtual key for an application. In the Admin UI click Virtual Keys in the sidebar, then + Create New Key, type a Key Name such as
laptop-test, pick the model under Models and click Create Key. Copy the key from the Save your Key dialog, because it is shown once. From the command line:curl -X POST http://localhost:4000/key/generate \-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \-d '{"key_alias": "laptop-test", "models": ["claude-sonnet-5-5"]}'Open Logs in the Admin UI to see every request with its model, tokens and cost.
-
Stop and start it again when you like. Your models, keys and logs are kept in the volume.
docker stop spanway-devdocker start spanway-dev
Limits
Dev mode trades safety and scale for a quick start. Each limit below is a reason not to run it for real work.
| Limit | What it means for you |
|---|---|
| One container holds everything | If the container or the laptop stops, the gateway stops. There is no second copy to take over. |
| The database lives in one Docker volume | There are no backups. Deleting the volume, or Docker Desktop resetting its disk, deletes every key, model and log. |
| No Redis | Rate limits, budgets in progress and the response cache are counted inside this one process. That is correct for one container and wrong as soon as there are two. |
| Small, untuned database | The built-in PostgreSQL 18 uses its default settings and a few hundred megabytes of memory. It is fine for a person trying things and slow under real traffic. |
| Runs as the image's own user | The database refuses to start as an arbitrary user id, so platforms that assign one (for example OpenShift's restricted policy) cannot run the dev image. |
| Not reachable from outside by default | The commands above publish the port on 127.0.0.1 only. Publishing it on every address puts an admin login on your network, so do not change that. |
The gateway prints this reminder as the first line of every start: Spanway dev mode: the database runs inside this container and there is no Redis. Use it on a laptop to try the gateway, never for production or shared use.
Settings
Dev mode reads the same environment variables as the normal image, with these differences.
| Variable | Default in dev mode | What it does | When it is off or unset |
|---|---|---|---|
SPANWAY_MASTER_KEY | none, it is required | The admin key of the gateway and the Admin UI password for admin. Generate it as in step 2. | The gateway refuses to start, exactly as the normal image does. |
SPANWAY_SALT_KEY | the master key | Encrypts the provider keys stored in the database. Set it once and keep it. | The master key is used instead, so changing the master key later also needs a master key migration. |
STORE_MODEL_IN_DB | True | Lets you add and edit models from the Admin UI and POST /model/new without a restart. Dev mode turns it on because a quick try usually starts with no config file. | Set it to False to use only the models in a config file you mount and pass with --config. |
DATABASE_URL | set by dev mode | Dev mode points the gateway at its own database on 127.0.0.1:5432 inside the container. | Setting it yourself is refused, see errors. To use your own PostgreSQL, run the normal spanway-ai image. |
Arguments after the image name go to the gateway, the same as with the normal image, so --config /app/config.yaml or --detailed_debug work as usual. Every other variable is in the environment variable reference.
The volume holds two things in /var/lib/spanway/dev: the database files in postgres and the database password in database_password. The password is generated on the first start, is readable only by the container user and is never written to the logs. The database listens only inside the container, so publishing port 5432 does not expose it.
Start over or upgrade
To delete everything and start fresh:
docker rm -f spanway-dev
docker volume rm spanway-dev
To move to a newer release, stop and remove the container, pull the new tag and run step 3 again with the same volume. The gateway applies any new schema changes on start. A release that ships a newer major version of PostgreSQL cannot open a database made by the older one, and dev mode says so instead of starting, see errors. In that case start over with a new volume, since dev mode data is not meant to be kept.
Moving to a real deployment
Dev mode has no tool to move its data elsewhere, on purpose, because nothing important should live in it. When you are ready for real use, start fresh with one of these, all of which use your own PostgreSQL and, for more than one instance, Redis:
- Docker Compose for one server with a separate database.
- Helm for Kubernetes.
- Terraform for the cloud stacks.
Then go through the production checklist.
Errors
Dev mode prints these lines before the gateway starts, so they appear in docker logs spanway-dev and the container exits with code 1.
| Message | Meaning | Fix |
|---|---|---|
Spanway dev mode refused to start: DATABASE_URL is set, but dev mode always runs its own database. Unset DATABASE_URL, or run the spanway-ai image to use your own PostgreSQL. | A DATABASE_URL reached the container, often from an env file written for another setup. | Remove it from the env file, or use the spanway-ai image with your own database. |
Spanway dev mode refused to start: cannot write /var/lib/spanway/dev (Permission denied). Mount a named volume there, ... | The state folder is not writable, usually because a host folder was mounted there or the container runs as another user. | Use a named volume as in step 3 and do not pass --user. |
Spanway dev mode refused to start: the database in /var/lib/spanway/dev was made by PostgreSQL <old> and this image runs <new>. ... | The volume was created by a release with an older major version of PostgreSQL. | Start over with a new volume, or go back to the image version that created it. |
Spanway dev mode refused to start: /var/lib/spanway/dev/database_password is missing, ... | The database exists but its password file was deleted. | Start over with a new volume. |
Spanway dev mode refused to start: the database template /usr/share/spanway/devdb-template is missing. ... | The dev start command was run in an image other than spanway-ai-dev. | Run the spanway-ai-dev image. |
Spanway dev mode refused to start: the embedded database did not accept its new password. | The first start could not finish setting up the database. Nothing was kept, so the next start tries again. | Start the container again. If it repeats, start over with a new volume. |
Spanway dev mode refused to start: the embedded database exited during startup (exit <code>). | PostgreSQL stopped while starting. Its own message just above says why, for example a full disk. | Fix what the PostgreSQL line says, then start again. |
Spanway dev mode refused to start: the embedded database was not ready after 60 s. | PostgreSQL started but did not become ready in time, which happens on a very slow or overloaded machine. | Start the container again once the machine is less busy. |
Spanway proxy refused to start: no master key is set, ... | SPANWAY_MASTER_KEY did not reach the container. | Check that --env-file spanway-dev.env points at the file from step 2. |
Bind for 127.0.0.1:4000 failed: port is already allocated from docker run | Something else on this machine uses port 4000. | Use another port, for example -p 127.0.0.1:4100:4000, and call http://localhost:4100. |
Errors from requests, such as a 401 without a key or a 400 for an unknown model, are the same as in the normal image and are listed in the error reference.
Logs
Dev mode and its database write to the container output, so docker logs spanway-dev shows everything.
| Level | Line | Meaning | Action |
|---|---|---|---|
| Output | Spanway dev mode: the database runs inside this container and there is no Redis. Use it on a laptop to try the gateway, never for production or shared use. | Printed on every start as a reminder of the limits. | None. |
| Output | Spanway dev mode: created the embedded database in /var/lib/spanway/dev. | First start on a new volume. The database and its password were created. | None. |
| Output | Spanway dev mode: embedded database ready on 127.0.0.1:5432, starting the gateway. | The database is up and the gateway is starting. | None. |
| LOG | database system is ready to accept connections and other lines with a UTC [<pid>] LOG: prefix | PostgreSQL's own startup and shutdown messages. | None. |
| ERROR | relation "_prisma_migrations" does not exist on the first start | The gateway checked for applied schema changes before any existed. It then applies them. | None. |
| Output | Spanway dev mode: the embedded database stopped unexpectedly (exit <code>), stopping the gateway. | PostgreSQL stopped while the gateway was running, so the container stops too. | Read the PostgreSQL line above it, fix the cause and start again. |
| Output | Spanway dev mode: stopped the gateway and the embedded database. | A normal stop, for example after docker stop. The database shut down cleanly. | None. |
The gateway's own lines are the same as in the normal image and are listed in the log reference. Dev mode adds no metrics of its own, and the gateway's Prometheus metrics and traces work as usual.
Related
- Docker quick start for the normal image with a config file or with Postgres in Docker Compose.
- Container images for every image a release ships and how to verify its signature.
- Production checklist before real traffic.
- Virtual keys for what a key can limit.