API Playground page
The API Playground page shows how the gateway translates a request in the OpenAI chat completions format into the request it sends to a provider. You paste a request body, and the page returns the provider URL, headers and body as a curl command. Nothing is sent to the provider. Open it at /ui/transform-request. It sits under AI Gateway in the left nav as API Playground, although the heading on the page itself reads Playground.
The nav item is shown to the session roles Admin, Admin Viewer, Internal User and Internal Viewer. A proxy_admin_viewer signs in with the session role Admin Viewer and still sees it because the page changes nothing. Org admins do not see it, because the session role Org Admin is not in the list. When enabled_ui_pages_internal_users is set in UI settings, non-admin users see the item only if transform-request is in that list. The page has no guard of its own. The backend route it calls, POST /utils/transform_request, accepts any valid key and is treated as a non-spending route. No license feature is needed.
A real-world scenario
A request with reasoning_effort works with one provider and fails with another. The developer pastes the same body into the API Playground with each provider's model name and compares the two provider requests, which shows that the second provider gets the setting under a different field name.
Steps
-
Open API Playground under AI Gateway in the left nav, or go to
/ui/transform-request. -
Replace the sample body with your request and set
modelto a provider and model name such asopenai/gpt-5.5. -
Click Transform, or press Cmd+Enter or Ctrl+Enter. The page calls:
curl -X POST http://localhost:4000/utils/transform_request \-H "Authorization: Bearer $SPANWAY_API_KEY" -H "Content-Type: application/json" \-d '{"call_type": "completion", "request_body": {"model": "openai/gpt-5.5", "messages": [{"role": "user", "content": "Hi"}], "reasoning_effort": "low"}}' -
Change the model to another provider and transform again to compare.
Expected result
The right panel shows a curl command with the provider URL, headers and body, and a toast reads "Request transformed successfully". Nothing is sent to the provider and no real credential appears.
Original Request panel
| Control | Type | What it does |
|---|---|---|
| Request body | Code text area | The JSON body you would send to the gateway's /chat/completions endpoint. It starts with a sample that uses openai/gpt-4o, a system and a user message, temperature, max_tokens and stream. The model field takes a provider and model name in the provider prefix format, such as openai/gpt-4o. Press Cmd+Enter or Ctrl+Enter to transform. |
| Transform | Button | Parses the JSON and asks the gateway to build the provider request. It shows a spinner and is disabled while the request runs. |
The gateway first checks the body with the same request safety rules it applies to real calls, so client side credentials and endpoints such as api_base are rejected unless the admin has allowed them.
Transformed Request panel
The right panel shows the result as a curl command with the provider URL, the provider headers, Content-Type: application/json and the provider request body. Before the first transform it shows a sample command. The note "Sensitive headers are not shown." appears under the title. The transform runs with a placeholder API key, so no real provider credential is used or shown.
| Control | What it does |
|---|---|
| Copy (icon button) | Copies the transformed command and shows "Copied to clipboard". Before the first transform it copies an empty string, even though the sample command is on screen. |
When the gateway cannot build the request, for example because the provider or model is unknown, it returns an error object instead. The panel then shows the raw JSON response and a toast reads "Transformed request received in unexpected format".
Under the panels, "Found an error? File an issue here." links to the support page.
Empty, error and disabled states
| Situation | What you see |
|---|---|
| The body is not valid JSON | "Invalid JSON in request body". Nothing is sent. |
| The session has no key | "No access token found". |
| The request to the gateway fails | "Failed to transform request". |
| The gateway rejects the body | A toast with the gateway's error message, then "Failed to transform request". |
| The gateway returns an error object | The raw JSON in the right panel and "Transformed request received in unexpected format". |
| A transform succeeds | "Request transformed successfully" and the new command in the right panel. |
The Transform button is only disabled while a transform is running.
Differences by role and license
The page works the same for every role that can open it, because it only reads. Its output does not depend on the caller's key, team or model access, since the transform uses the model string in the body rather than the gateway's configured model groups. No license feature applies.
Errors
| What you see | What it means | Fix |
|---|---|---|
| "Invalid JSON in request body" | The body does not parse. | Fix the JSON. |
A toast with Rejected Request: <field> is not allowed in request body. ... or Rejected Request: model_list is not allowed in the request body., then "Failed to transform request" | The body names client side credentials, an api_base or a model_list the admin has not allowed. | Remove those fields, see the error reference. |
| "Transformed request received in unexpected format" with raw JSON | The gateway could not build the request, for example the provider or model is unknown. | Check the provider prefix in model. |
| "No access token found" | The session has no key. | Sign in again. |
Logs
The API Playground only builds the provider request and never sends it, so nothing shows up on the Logs page, no spend is recorded and no audit row is written. The gateway writes no log line for a preview. A refused body is answered with the 400 above and is not logged either.