The InstaSD API allows seamless integration of generative workflows into your own applications. Here's a step-by-step guide:
1. Accessing API Instructions
Navigate to your API and click on "API Instructions".
This will display all available endpoints for your integration.
For most use cases, you'll only need two endpoints:
Run Task β To start a generation.
Task Status β To monitor the status of a generation.
2. Authentication
Include the following header in all API requests:
Authorization: Bearer <Your API Token>
Each API has a unique token. Ensure you're using the correct token for the corresponding API.
3. Starting a Generation
Endpoint:
βPOST <Your API URL>/run_task
Sample Request Body:
Replace the placeholders with appropriate values from your API instructions.
{ "inputs": { "7b7fae99f81ef925": { "title": "Prompt", "value": "Woman sitting on a chair with a cheetah in front of her" }, "b0c46c069a9e96c8": { "title": "Output Width", "value": 880 }, "b138cda90d074df1": { "title": "Output Height", "value": 1176 }, "7200c51e92f780da": { "title": "Steps (8-12)", "value": 12 }, "d228a236441bc317": { "title": "Strength (0-1)", "value": 0.3 }, "1db050bbc968f384": { "title": "Batch Size", "value": 1 }, "94c18e9e703d2087": { "title": "InstaSD API Input - Seed", "value": 42 }, "1022e871b44ce7f6": { "title": "Skip lora?", "value": "2" }, "8428ca86f40f597d": { "title": "Load Image", "value": "publicly available URL for the image" }, "239f8aef5854078c": { "title": "InstaSD API Input - Lora Loader", "value": "" } } }
Key Notes for Input Values:
Images: Use a publicly available URL (e.g., S3 signed URL for privacy). If not possible, you can use a base64-encoded image, but the payload must remain under 10 MB.
Videos: Provide a public URL.
Loras: Use a public link if the input relies on the InstaSD Lora Loader.
Seed: Randomize the seed programmatically in your code. The "Auto Randomize" setting in the UI does not apply to API calls.
Response Example for Run Task
:
{ "task_id": "unique-task-id-123", "status": "CREATED", "estimated_steps": 10 }
task_id
: A unique identifier for the task.status
: The task's current state (e.g.,CREATED
,IN_PROGRESS
,COMPLETED
).estimated_steps
: Total number of steps for this task.
4. Checking Task Status
Endpoint:
βGET <Your API URL>/task_status/:task_id
Use the task_id
from the Run Task
response to monitor the task's progress.
Response Example for Task Status
:
{ "task_id": "unique-task-id-123", "status": "IN_PROGRESS", "estimated_steps": 10, "completed_steps": 3, "image_urls": [], "video_urls": [], "delay_time": 5, "execution_time": 15, "cost": 0.05 }
Response Details:
status
: Current task status (e.g.,IN_QUEUE
,IN_PROGRESS
,COMPLETED
,FAILED
).image_urls
: URLs for generated images (expires after 30 minutes).video_urls
: URLs for generated videos (if applicable).execution_time
: Total processing time in seconds.cost
: Computational cost in credits.
Postman Collection for Easy Testing
The Postman collection includes all necessary endpoints for your API, pre-configured for your instance.
It also includes your API Key, so you can try out and test the endpoints locally.
Important: Your API key is sensitive and should be kept private. Avoid sharing it or committing it to public repositories.