API Reference page
The API Reference page shows sample Python code for calling the gateway with clients that speak the OpenAI API, with this gateway's base URL already filled in. Open it at /ui/api-reference. It sits under Developer Tools in the left nav as API Reference.
The nav item has no role restriction, so every signed-in role sees it. When enabled_ui_pages_internal_users is set in UI settings, non-admin users see the item only if api_ref is in that list. The page has no guard of its own and calls no protected route beyond loading proxy settings. No license feature is needed.
A real-world scenario
A new engineer has a virtual key and wants to call the gateway from an existing Python app that uses the OpenAI SDK. They open the API Reference page, copy the sample with this gateway's base URL already filled in, put their key in place of your_virtual_key, and their app runs through the gateway without other changes.
Steps
-
Open API Reference under Developer Tools in the left nav, or go to
/ui/api-reference. -
Keep the OpenAI Python SDK tab and click the copy button on the code block.
-
Replace
your_virtual_keywith your virtual key and the model with a model group your key can call. To list those:curl http://localhost:4000/v1/models -H "Authorization: Bearer $SPANWAY_API_KEY" -
Run the sample.
Expected result
The sample prints a chat completion, and the request shows on the Logs page under your key.
Deprecation banner
A banner at the top reads "The API Reference tab is on a draft deprecation list" and explains that it is one of several experimental features that may be removed in a future release, that no removal date is set, and that you can tell the team through the Spanway support link if you rely on it. The Close (X) button hides the banner until the page is loaded again.
Header
The heading reads OpenAI Compatible Proxy: API Reference. The API Reference Docs button on the right opens the "Calling the gateway" documentation in a new tab. Under the heading the page explains that your key works with the OpenAI SDK once you point its base URL at the gateway.
Code samples
Three tabs hold the samples. Each has a copy button on the code block.
| Tab | What the sample shows |
|---|---|
| OpenAI Python SDK (default) | Creating an OpenAI client with api_key and base_url set to the gateway URL plus /v1, then a chat completion. |
| LlamaIndex | Setting Settings.llm to OpenAILike and Settings.embed_model to OpenAIEmbedding, both pointed at the gateway URL plus /v1, then building and querying a vector index. It needs the llama-index-core, llama-index-llms-openai-like and llama-index-embeddings-openai packages. |
| Langchain Py | Pointing ChatOpenAI from langchain_openai at the gateway URL plus /v1 with base_url and api_key, then calling chat.invoke with a system and a human message. |
The base URL in the samples is chosen in this order, and the samples add /v1 to it because these OpenAI style clients expect it. It is the SPANWAY_UI_API_DOC_BASE_URL environment variable on the gateway container when the operator has set it, which is unset by default and has no Admin UI control or config key, otherwise the PROXY_BASE_URL environment variable, otherwise the literal placeholder <your_proxy_base_url>. Changing either needs a restart.
The samples are static. They do not use your key, your models or your team, so replace your_virtual_key with a virtual key and your-model-name with a public model name from GET /v1/models for that key. Never paste the master key into an application.
Empty, error and disabled states
The page has no empty or error states of its own. If the proxy settings cannot be loaded, the samples show <your_proxy_base_url> in place of the gateway URL. Nothing on the page is ever disabled.
Differences by role and license
The page is the same for every role, and no license feature applies. Only the base URL differs between gateways, depending on the proxy settings above.
Errors
| What you see | What it means | Fix |
|---|---|---|
The samples show <your_proxy_base_url> | Neither SPANWAY_UI_API_DOC_BASE_URL nor PROXY_BASE_URL is set. | Replace the placeholder with the gateway URL, or ask the operator to set one of the environment variables. |
401 when the sample runs | The key in the sample is a placeholder or wrong. | Paste your virtual key. |
400 with Invalid model name passed in model=<name> | The sample's model name is not served by this gateway. | Use a name from /v1/models. |
Logs
This page writes no log lines, it only reads the proxy settings once when it opens.