How to access comfyui by API?
Closed this issue · 2 comments
I deployed a comfyui server, but could access it by API, I am using the script example of comfyui, but got error reported.
#This is an example that uses the websockets api to know when a prompt execution is done
#Once the prompt execution is done it downloads the images using the /history endpoint
import websocket #NOTE: websocket-client (https://github.com/websocket-client/websocket-client)
import uuid
import json
import urllib.request
import urllib.parse
server_address = "xxxx.modal.run"
client_id = str(uuid.uuid4())
def queue_prompt(prompt):
p = {"prompt": prompt, "client_id": client_id}
data = json.dumps(p).encode('utf-8')
req = urllib.request.Request("http://{}/prompt".format(server_address), data=data)
return json.loads(urllib.request.urlopen(req).read())
error as following
Traceback (most recent call last):
File "xxx\websockets_api_example.py", line 154, in
ws.connect("ws://{}/ws?clientId={}".format(server_address, client_id))
File "xxx\venv\lib\site-packages\websocket_core.py", line 266, in connect
self.sock, addrs = connect(
File "xxx\venv\lib\site-packages\websocket_http.py", line 128, in connect
hostname, port_from_url, resource, is_secure = parse_url(url)
File "xxx\venv\lib\site-packages\websocket_url.py", line 62, in parse_url
raise ValueError("scheme %s is invalid" % scheme)
ValueError: scheme https is invalid
This seems like an issue unrelated to Modal – you're trying to open a websocket connection to a https:// endpoint - it should be ws://
I have tried ws://, and other method. It failed