One of the challenges when starting with any API is knowing exactly which parameters to use. Scenario makes this easy by letting you derive parameters directly from the web application:
Start by performing the action you want to replicate in the Scenario web application. For example, generate an image with specific settings or train a model with particular parameters.
Before performing the action:
Right-click anywhere on the page and select "Inspect" to open your browser's Developer Tools. You can also press Ctrl+Shift+I
(Windows/Linux) or Cmd+Option+I
(Mac) to open the browser's Developer Tools.
Navigate to the "Network" tab
Filter the requests to show only "Fetch/XHR" to focus on API calls
Perform the action on the webapp that you want to replicate via the API. For example, if you’re triggering an inference, initiate the generation process. As this action is performed, you’ll see a series of requests appear in the Network tab.
Pay close attention to the requests related to the workflow. For instance, when triggering an inference, you'll notice a POST request followed by several GET job requests as the process unfolds.
Look for the relevant POST request (e.g., a request to /generate/txt2img
for image generation) and click on each request to view its details.
To find the correct API parameters, examine the "Payload" section of the POST request. This section shows the data sent to the server, which includes the parameters you’ll need to replicate the workflow via the API. You can also check the "Response" section to understand the server's reply, which can provide additional insights into what data is required or expected.
POST Payload
POST Response
GET /jobs/{jobId} Response during generation progress
Once you've identified the necessary parameters and understood the request flow, you can use this information to construct your API calls. With these parameters, you can replicate the exact workflow from the webapp using the API, ensuring consistency across both platforms.
Was this helpful?
Quentin