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:
Step 1: Use the Web Interface as a Guide
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.
Step 2: Inspect the Network Requests
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) orCmd+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
Step 3: Trigger the Workflow
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.
Step 4: Examine the Requests
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.
Step 5: Review the Payload and Response
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
Step 6: Replicate the Workflow with the API
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?