Setup wizard
spanway --setup walks a first-time user from an empty directory to a running gateway in one terminal session. It asks which providers to serve, takes an API key for each and checks it against the provider, asks for a port and a master key, writes spanway_config.yaml into the current directory and offers to start the gateway with it. It is the fastest route to a working config file when you do not yet know the config file format.
docker run --rm -it --user "$(id -u):$(id -g)" -p 4000:4000 -v "$PWD:/app/work" -w /app/work registry.spanway.ai/spanway/spanway-ai:2.0.0 --setup
The wizard runs inside the gateway image. Mounting the current directory at /app/work puts the config file it writes on the host, --user runs it as your own user so that file belongs to you and the write succeeds on a Linux host, and publishing port 4000 makes the gateway it starts at the end reachable.
The wizard runs inside the gateway image, so it works the same from macOS, Linux and Windows. It uses arrow-key selection whenever docker run gets -it, and falls back to numbered input when no terminal is attached. Ctrl-C at any prompt cancels it without writing anything.
A real-world scenario
A developer wants to try the gateway with their OpenAI and Anthropic keys during a lunch break, without learning the config format first. They run the wizard in an empty folder, paste both keys, and two minutes later point their existing OpenAI SDK script at http://localhost:4000.
Steps
-
Open an empty directory and start the wizard with the
docker run ... --setupcommand above. -
Pick the providers with Space and press Enter, then paste each API key when asked. The wizard checks each key against the provider.
-
Accept port 4000 and leave the master key blank to generate one.
-
Answer yes to start the gateway now.
-
In another terminal, check that it answers.
curl http://localhost:4000/health/livelinesscurl http://localhost:4000/v1/models -H "Authorization: Bearer <master key from spanway_config.yaml>" -
Open
http://localhost:4000/uiand sign in with the master key. The Models + Endpoints page lists the models the wizard wrote.
Expected result
spanway_config.yaml holds a model_list entry per provider and the master key, /v1/models lists those models, and a chat completion to one of them answers through the gateway.
What it asks
The first screen is a multi-select of providers. Space toggles a provider and Enter confirms.
| Provider | Key it asks for | Validated against | Models written to the config |
|---|---|---|---|
| OpenAI | OPENAI_API_KEY | gpt-6-luna | gpt-6.1-sol, gpt-6-luna |
| Anthropic | ANTHROPIC_API_KEY | claude-haiku-5-5 | The Claude line from claude-fable-5-1 down to claude-haiku-5-5, plus claude-haiku-4-5-20251001 |
| Google Gemini | GEMINI_API_KEY | gemini/gemini-3.8-flash | gemini/gemini-3.8-flash, gemini/gemini-3.1-pro-preview |
| Azure OpenAI | AZURE_AI_API_KEY, plus the endpoint URL and a deployment name | not validated, a deployment is needed first | azure/<deployment> with api_version set, published as azure-<deployment> |
| AWS Bedrock | AWS_ACCESS_KEY_ID, then AWS_SECRET_ACCESS_KEY and AWS_REGION_NAME | not validated | bedrock/us.anthropic.claude-haiku-5-5, signed with aws_access_key_id, aws_secret_access_key and aws_region_name |
| Ollama | none | not validated | ollama/llama3.2, ollama/mistral with api_base: http://localhost:11434 |
For each provider with a key, the wizard calls the provider once with the validation model. A key that fails can be re-entered or kept anyway. Leaving a key blank and confirming the skip leaves that provider out of the config entirely.
The last two prompts are the port, default 4000, and the master key. Leaving the master key blank generates one in the form sk- followed by a random token.
What it writes
The config is written to spanway_config.yaml in the working directory. Provider keys are referenced from the model_list as os.environ/NAME and the values themselves go under environment_variables, which the gateway loads into its process environment at start. The master key is written under general_settings.
model_list:
- model_name: claude-sonnet-5-5
spanway_params:
model: claude-sonnet-5-5
api_key: os.environ/ANTHROPIC_API_KEY
general_settings:
master_key: "sk-..."
environment_variables:
ANTHROPIC_API_KEY: "sk-ant-..."
Because the keys end up in the file, add spanway_config.yaml to .gitignore or move the values into real environment variables before committing it. Azure entries carry api_base and api_version: 2024-07-01-preview, and Ollama entries carry api_base with no key. Bedrock entries carry aws_access_key_id: os.environ/AWS_ACCESS_KEY_ID, aws_secret_access_key: os.environ/AWS_SECRET_ACCESS_KEY and aws_region_name: os.environ/AWS_REGION_NAME instead of an api_key, so the gateway signs each Bedrock call with those AWS credentials.
Starting the gateway
After writing the file the wizard prints the start command, the two environment variables an OpenAI SDK needs to point at the gateway, and a quick test with curl http://localhost:<port>/health/liveliness, which needs no key, and asks whether to start now. Answering yes replaces the wizard process with spanway --config spanway_config.yaml --port <port> inside the container, so Ctrl-C stops the gateway. Answering no leaves you with the command to run later, which from the host is the same image started with the config file mounted.
docker run --user "$(id -u):$(id -g)" -p 4000:4000 -v "$PWD:/app/work" -w /app/work \
registry.spanway.ai/spanway/spanway-ai:2.0.0 --config spanway_config.yaml --port 4000
export OPENAI_BASE_URL=http://localhost:4000
export OPENAI_API_KEY=sk-...
curl http://localhost:4000/health/liveliness
The Admin UI is at http://localhost:4000/ui and logs in with the master key. From there the CLI manages keys and models against the running gateway, and the production checklist covers what to change before real traffic.
Errors
| What you see | What it means | Fix |
|---|---|---|
| The key check fails for a provider | The provider refused the key, or the network blocks it. | Re-enter the key, or keep it anyway and fix it in the config later. |
Permission denied writing spanway_config.yaml | The container user cannot write the mounted directory. | Keep --user "$(id -u):$(id -g)" in the command. |
| The gateway starts but the host cannot reach it | Port 4000 was not published. | Add -p 4000:4000. |
401 with the master key | The key was mistyped. | Copy it from general_settings.master_key in the file. |
Logs
The wizard prints to the terminal only and writes no log file. Besides the questions, these lines are worth knowing:
| Line | Meaning | Action needed |
|---|---|---|
Could not write config: <reason> | The config file could not be written into the mounted folder, so nothing was saved. | Fix the folder permissions, usually with --user "$(id -u):$(id -g)", and run the wizard again. |
Could not start proxy: <reason> | The config was written, but starting the gateway from it failed. | Start the gateway yourself with the command the wizard printed and read its error. |
Keys are stored only in the generated config file. | A reminder that the keys you typed are saved in plain text in that file. | Keep the file private, or move the keys to environment variables. |
Quick test once running: curl http://localhost:<port>/health/liveliness | The command that checks the gateway answers, without a key. | Run it after the gateway starts. |
Related
- Config file for everything the file can hold.
- Docker quick start for starting without the wizard.
- Production checklist before real traffic.