@@ -51,7 +51,7 @@ CUDA_VISIBLE_DEVICES=1 sglang serve \
5151 --model-path Qwen/Qwen-Image \
5252 --num-gpus 1 \
5353 --host 127.0.0.1 \
54- --port 30001
54+ --port 30002
5555```
5656
5757### Start the router
@@ -60,21 +60,22 @@ CUDA_VISIBLE_DEVICES=1 sglang serve \
6060
6161``` bash
6262sglang-d-router --port 30081 \
63- --worker-urls http://localhost:30000 http://localhost:30001
63+ --worker-urls http://localhost:30000 http://localhost:30002
6464```
6565
66662 . Module entry
6767
6868``` bash
6969python -m sglang_diffusion_routing --port 30081 \
70- --worker-urls http://localhost:30000 http://localhost:30001
70+ --worker-urls http://localhost:30000 http://localhost:30002
7171```
7272
73733 . Or start empty and add workers later:
7474
7575``` bash
7676sglang-d-router --port 30081
7777curl -X POST " http://localhost:30081/add_worker?url=http://localhost:30000"
78+ curl -X POST " http://localhost:30081/add_worker?url=http://localhost:30002"
7879```
7980
8081### Test the router
@@ -125,6 +126,50 @@ curl -X POST http://localhost:30081/generate_video \
125126curl http://localhost:30081/health_workers
126127```
127128
129+ ### Python requests examples
130+
131+ ``` python
132+ import requests
133+ import base64
134+
135+ ROUTER = " http://localhost:30081"
136+
137+ # Check router health
138+ resp = requests.get(f " { ROUTER } /health " )
139+ print (resp.json())
140+
141+ # List registered workers
142+ resp = requests.get(f " { ROUTER } /list_workers " )
143+ print (resp.json())
144+
145+ # Image generation request (returns base64-encoded image)
146+ resp = requests.post(f " { ROUTER } /generate " , json = {
147+ " model" : " Qwen/Qwen-Image" ,
148+ " prompt" : " a cute cat" ,
149+ " num_images" : 1 ,
150+ " response_format" : " b64_json" ,
151+ })
152+ data = resp.json()
153+ print (data)
154+
155+ # Decode and save the image locally
156+ img = base64.b64decode(data[" data" ][0 ][" b64_json" ])
157+ with open (" output.png" , " wb" ) as f:
158+ f.write(img)
159+ print (" Saved to output.png" )
160+
161+ # Video generation request
162+ resp = requests.post(f " { ROUTER } /generate_video " , json = {
163+ " model" : " Qwen/Qwen-Image" ,
164+ " prompt" : " a flowing river" ,
165+ })
166+ print (resp.json())
167+
168+ # Check per-worker health and load
169+ resp = requests.get(f " { ROUTER } /health_workers " )
170+ print (resp.json())
171+ ```
172+
128173## Router API
129174
130175- ` POST /add_worker ` : add worker via query (` ?url= ` ) or JSON body.
0 commit comments