2025-08-25 18:31:10 +01:00
|
|
|
from .data_types import count_workload
|
2025-11-11 17:09:28 -08:00
|
|
|
import uuid
|
|
|
|
|
import random
|
|
|
|
|
import asyncio
|
|
|
|
|
import random
|
2025-08-25 18:31:10 +01:00
|
|
|
|
2025-11-11 17:11:38 -08:00
|
|
|
from vastai import Serverless
|
|
|
|
|
|
2025-11-11 17:09:28 -08:00
|
|
|
async def main():
|
|
|
|
|
async with Serverless() as client:
|
|
|
|
|
endpoint = await client.get_endpoint(name="my-comfy-endpoint") # Change this to your endpoint name
|
|
|
|
|
|
|
|
|
|
payload = {
|
|
|
|
|
"input": {
|
|
|
|
|
"request_id": str(uuid.uuid4()),
|
|
|
|
|
"modifier": "Text2Image",
|
|
|
|
|
"modifications": {
|
|
|
|
|
"prompt": "a beautiful landscape with mountains and lakes",
|
|
|
|
|
"width": 1024,
|
|
|
|
|
"height": 1024,
|
|
|
|
|
"steps": 20,
|
|
|
|
|
"seed": random.randint(0, 2**32 - 1)
|
|
|
|
|
},
|
|
|
|
|
"workflow_json": {} # Empty since using modifier approach
|
|
|
|
|
}
|
2025-08-25 18:31:10 +01:00
|
|
|
}
|
2025-11-11 17:09:28 -08:00
|
|
|
|
|
|
|
|
response = await endpoint.request("/generate/sync", payload, cost=count_workload())
|
2025-08-19 17:59:20 +01:00
|
|
|
|
2025-11-11 17:09:28 -08:00
|
|
|
# Get the file from the path on the local machine using SCP or SFTP
|
|
|
|
|
# or configure S3 to upload to cloud storage.
|
|
|
|
|
print(response["response"]["output"][0]["local_path"])
|
2025-08-19 17:59:20 +01:00
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2025-11-11 17:09:28 -08:00
|
|
|
asyncio.run(main())
|