Skip to main content

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​

  1. Open an empty directory and start the wizard with the docker run ... --setup command above.

  2. Pick the providers with Space and press Enter, then paste each API key when asked. The wizard checks each key against the provider.

  3. Accept port 4000 and leave the master key blank to generate one.

  4. Answer yes to start the gateway now.

  5. In another terminal, check that it answers.

    curl http://localhost:4000/health/liveliness
    curl http://localhost:4000/v1/models -H "Authorization: Bearer <master key from spanway_config.yaml>"
  6. Open http://localhost:4000/ui and 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.

ProviderKey it asks forValidated againstModels written to the config
OpenAIOPENAI_API_KEYgpt-6-lunagpt-6.1-sol, gpt-6-luna
AnthropicANTHROPIC_API_KEYclaude-haiku-5-5The Claude line from claude-fable-5-1 down to claude-haiku-5-5, plus claude-haiku-4-5-20251001
Google GeminiGEMINI_API_KEYgemini/gemini-3.8-flashgemini/gemini-3.8-flash, gemini/gemini-3.1-pro-preview
Azure OpenAIAZURE_AI_API_KEY, plus the endpoint URL and a deployment namenot validated, a deployment is needed firstazure/<deployment> with api_version set, published as azure-<deployment>
AWS BedrockAWS_ACCESS_KEY_ID, then AWS_SECRET_ACCESS_KEY and AWS_REGION_NAMEnot validatedbedrock/us.anthropic.claude-haiku-5-5, signed with aws_access_key_id, aws_secret_access_key and aws_region_name
Ollamanonenot validatedollama/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 seeWhat it meansFix
The key check fails for a providerThe 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.yamlThe container user cannot write the mounted directory.Keep --user "$(id -u):$(id -g)" in the command.
The gateway starts but the host cannot reach itPort 4000 was not published.Add -p 4000:4000.
401 with the master keyThe 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:

LineMeaningAction 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/livelinessThe command that checks the gateway answers, without a key.Run it after the gateway starts.