Skip to content

Commit b15d0a2

Browse files
uzunenescursoragent
andcommitted
docs: add sample outputs (images) and fetch script; README references
- examples/sample_outputs/: sunset_istanbul, cat_astronaut, cappadocia_balloons (nice prompts) - fetch_sample_outputs.py: generate + download images and optional video - README and examples/README: Sample outputs section with table and images - sample_outputs/README: prompt list and regenerate instructions Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 24fa28f commit b15d0a2

7 files changed

Lines changed: 124 additions & 0 deletions

File tree

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,22 @@ See the [`examples/`](examples/) directory for tested scripts covering every SDK
216216
VISGATE_API_KEY=vg-... python examples/run_all_capabilities.py
217217
```
218218

219+
### Sample outputs (image & video)
220+
221+
Example results from the API with curated prompts are under [`examples/sample_outputs/`](examples/sample_outputs/). You can regenerate them with:
222+
223+
```bash
224+
cd examples && python fetch_sample_outputs.py
225+
```
226+
227+
| Prompt | Output |
228+
|--------|--------|
229+
| Golden hour sunset over Istanbul Bosphorus... | ![Sunset Istanbul](examples/sample_outputs/sunset_istanbul.jpg) |
230+
| A fluffy orange cat astronaut in space... | ![Cat astronaut](examples/sample_outputs/cat_astronaut.jpg) |
231+
| Cappadocia hot air balloons at dawn... | ![Cappadocia](examples/sample_outputs/cappadocia_balloons.jpg) |
232+
233+
Video (async): run `fetch_sample_outputs.py` to generate a short beach-waves clip; the script saves it to `sample_outputs/beach_waves.mp4` when the URL is ready.
234+
219235
## Contributing
220236

221237
See [CONTRIBUTING.md](CONTRIBUTING.md).

examples/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,14 @@ The first two steps run without an API key. `VISGATE_API_KEY` is required from s
4545
- **Exact cache:** Same model + prompt + size. Second request returns from cache; response includes `cache_hit=True` and `provider_cost_avoided_micro` (cost saved in micro-USD). Run `python examples/07_cache_demo.py`.
4646
- **Semantic cache:** Similar but different wording; API matches via Vertex AI embedding + Firestore. Second request may return `cache_hit=True` and `provider_cost_avoided_micro`. Run `python examples/08_semantic_cache_demo.py`.
4747
- Cache is org-scoped by default; see API docs for `VISGATE_CACHE_SCOPE` and TTL.
48+
49+
## Sample outputs
50+
51+
Generated image (and optional video) samples with nice prompts are saved in [`sample_outputs/`](sample_outputs/). To regenerate them:
52+
53+
```bash
54+
cd examples
55+
python fetch_sample_outputs.py
56+
```
57+
58+
Requires `VISGATE_API_KEY` and optionally `VISGATE_FAL_API_KEY`. Outputs: `sunset_istanbul.jpg`, `cat_astronaut.jpg`, `cappadocia_balloons.jpg`, and optionally `beach_waves.mp4` (video may be async).

examples/fetch_sample_outputs.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Generate sample images (and optionally video) with nice prompts and save to
4+
examples/sample_outputs/. Run with VISGATE_API_KEY and optionally VISGATE_FAL_API_KEY.
5+
6+
cd examples && python fetch_sample_outputs.py
7+
"""
8+
from __future__ import annotations
9+
10+
import os
11+
import sys
12+
from pathlib import Path
13+
14+
import httpx
15+
16+
# Add parent for _common
17+
sys.path.insert(0, str(Path(__file__).resolve().parent))
18+
19+
from _common import create_client
20+
21+
OUTPUT_DIR = Path(__file__).resolve().parent / "sample_outputs"
22+
23+
IMAGE_PROMPTS = [
24+
("sunset_istanbul", "Golden hour sunset over Istanbul Bosphorus, minarets and seagulls, cinematic, detailed, 8k"),
25+
("cat_astronaut", "A fluffy orange cat astronaut floating in space, Earth in the background, photorealistic, whimsical"),
26+
("cappadocia_balloons", "Cinematic drone shot of Cappadocia hot air balloons at dawn, soft light, detailed landscape"),
27+
]
28+
29+
VIDEO_PROMPT = ("beach_waves", "Waves crashing on a quiet beach at sunset, cinematic, 4k", 4.0)
30+
31+
32+
def download_url(url: str, path: Path, timeout: float = 60.0) -> None:
33+
with httpx.Client(timeout=timeout, follow_redirects=True) as client:
34+
r = client.get(url)
35+
r.raise_for_status()
36+
path.write_bytes(r.content)
37+
38+
39+
def main() -> int:
40+
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
41+
42+
with create_client() as client:
43+
# Images
44+
for name, prompt in IMAGE_PROMPTS:
45+
print(f"Generating image: {name} ...")
46+
result = client.images.generate(
47+
model="fal-ai/flux/schnell",
48+
prompt=prompt,
49+
width=1024,
50+
height=1024,
51+
num_images=1,
52+
)
53+
if not result.images:
54+
print(f" No image URL for {name}", file=sys.stderr)
55+
continue
56+
url = result.images[0]
57+
ext = ".png" if ".png" in url.split("?")[0].lower() else ".jpg"
58+
path = OUTPUT_DIR / f"{name}{ext}"
59+
download_url(url, path)
60+
print(f" Saved {path}")
61+
62+
# Video (one short clip)
63+
vname, vprompt, vdur = VIDEO_PROMPT
64+
print(f"Generating video: {vname} ...")
65+
try:
66+
vresult = client.videos.generate(
67+
model="fal-ai/flux-pro/video",
68+
prompt=vprompt,
69+
duration_seconds=vdur,
70+
)
71+
if vresult.video_url:
72+
vpath = OUTPUT_DIR / f"{vname}.mp4"
73+
download_url(vresult.video_url, vpath, timeout=120.0)
74+
print(f" Saved {vpath}")
75+
else:
76+
print(" Video URL not ready (async); skip download")
77+
except Exception as e:
78+
print(f" Video skipped: {e}")
79+
80+
print(f"\nSample outputs in {OUTPUT_DIR}")
81+
return 0
82+
83+
84+
if __name__ == "__main__":
85+
sys.exit(main())

examples/sample_outputs/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Sample outputs
2+
3+
Example images (and optionally video) generated with the Visgate API via `fetch_sample_outputs.py`.
4+
5+
| File | Prompt |
6+
|------|--------|
7+
| `sunset_istanbul.jpg` | Golden hour sunset over Istanbul Bosphorus, minarets and seagulls, cinematic, detailed, 8k |
8+
| `cat_astronaut.jpg` | A fluffy orange cat astronaut floating in space, Earth in the background, photorealistic, whimsical |
9+
| `cappadocia_balloons.jpg` | Cinematic drone shot of Cappadocia hot air balloons at dawn, soft light, detailed landscape |
10+
| `beach_waves.mp4` | Waves crashing on a quiet beach at sunset (async; run the script to generate when ready) |
11+
12+
Regenerate: from `examples/`, run `python fetch_sample_outputs.py` (requires `VISGATE_API_KEY`).
254 KB
Loading
169 KB
Loading
268 KB
Loading

0 commit comments

Comments
 (0)