You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Visgate is a visual AI gateway: one API, one SDK, three providers. Generate images and videos with Fal, Replicate, or Runway — managed keys or bring your own. Built-in cache, usage tracking, and typed exceptions.
13
+
10
14
## Install
11
15
12
16
```bash
@@ -26,7 +30,7 @@ print(result.image_url)
26
30
client.close()
27
31
```
28
32
29
-
Or with a context manager:
33
+
With a context manager:
30
34
31
35
```python
32
36
with Client() as client:
@@ -38,28 +42,29 @@ with Client() as client:
38
42
39
43
-**One client, three providers.** Fal, Replicate, and Runway behind a single API.
40
44
-**Managed and BYOK modes.** Use Visgate-managed keys or bring your own.
41
-
-**Sync and async.**`Client` for synchronous code, `AsyncClient` for async.
42
-
-**Automatic retries.** Transient errors (429, 5xx) are retried with exponential backoff.
43
-
-**Typed exceptions.** Catch `AuthenticationError`, `RateLimitError`, `ProviderError`, etc.
44
-
-**Full type hints.** PEP 561 compliant with `py.typed` marker.
45
+
-**Sync and async.**`Client` for sync, `AsyncClient` for async.
46
+
-**Async 202 + poll.**`videos.generate(wait=False)` / `images.generate(wait=False)` for long-running jobs; poll with `client.requests.get()`.
47
+
-**Automatic retries.** Transient errors (429, 5xx) with exponential backoff.
48
+
-**Typed exceptions.**`AuthenticationError`, `RateLimitError`, `ProviderError`, etc.
49
+
-**Full type hints.** PEP 561 compliant.
45
50
46
51
## Authentication
47
52
48
-
Set your API key as an environment variable (recommended):
53
+
Set your API key (required for most endpoints):
49
54
50
55
```bash
51
56
export VISGATE_API_KEY="vg-..."
52
57
```
53
58
54
-
Or pass it directly:
59
+
Or pass directly:
55
60
56
61
```python
57
62
client = Client(api_key="vg-...")
58
63
```
59
64
60
65
## BYOK (Bring Your Own Key)
61
66
62
-
Use your own provider keys while still routing through Visgate:
67
+
Use your own provider keys while routing through Visgate:
63
68
64
69
```python
65
70
client = Client(
@@ -95,7 +100,7 @@ result = client.videos.generate(
95
100
prompt="Cinematic drone over Istanbul at golden hour, Bosphorus and minarets",
96
101
duration_seconds=5.0,
97
102
)
98
-
print(result.video_url)# Convert to GIF for previews: examples/make_video_and_gif.py --mp4 path
103
+
print(result.video_url)
99
104
```
100
105
101
106
### Model Discovery
@@ -196,38 +201,35 @@ All API traffic uses HTTPS. Provider API keys (BYOK) are encrypted at rest; othe
196
201
197
202
## Examples
198
203
199
-
A **step-by-step guide** with purpose, command, and proof output for each example is in [examples/README.md](examples/README.md) (textbook-style with all results).
204
+
A step-by-step guidefor each example is in [examples/README.md](examples/README.md).
200
205
201
206
| Script | Description | Auth |
202
207
|--------|-------------|:---:|
203
-
|`00_smoke_sdk.py`|Version and client (no network) | No |
204
-
|`01_live_api_smoke.py`| Health check and model listing | No |
208
+
|`00_smoke_sdk.py`|SDK version and client (no network) | No |
209
+
|`01_live_api_smoke.py`| Health and model listing | No |
# Capture all text outputs to sample_outputs/out_*.txt
223
-
cd examples && python capture_all_outputs.py
224
-
```
229
+
# Run with a credentials file (e.g. sifreler in repo root)
230
+
python examples/run_with_sifreler.py
225
231
226
-
Sample outputs use an **Istanbul theme** (Bosphorus, minarets, golden hour). They are under [`examples/sample_outputs/`](examples/sample_outputs/) (images, `istanbul.mp4`, `istanbul.gif`, and text proofs). Regenerate:
227
-
228
-
```bash
229
-
cd examples && python fetch_sample_outputs.py # images + video
230
-
cd examples && python make_video_and_gif.py # video + GIF
232
+
# Low-cost run (no generation): see examples/README.md
Copy file name to clipboardExpand all lines: docs/API.md
+71-25Lines changed: 71 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,37 +1,34 @@
1
1
# API reference
2
2
3
-
Short reference. Full OpenAPI spec: your API base URL + `/docs`.
3
+
Short reference for the **visgate-python** SDK. Full OpenAPI spec: **https://visgateai.com/api/v1/docs** (or your base URL + `/docs`).
4
4
5
5
## Testing against the live API
6
6
7
-
Use the **visgate-python**SDK and examples to hit the live API. Sample outputs (images and video) use an **Istanbul theme**for a consistent look.
7
+
Use the SDK and the numbered examples to hit the live API. Sample outputs use an **Istanbul theme**(Bosphorus, Galata Tower, golden hour).
8
8
9
9
```bash
10
10
pip install visgate-sdk
11
11
export VISGATE_API_KEY=vg-...
12
12
13
-
# Health and models (minimal check)
13
+
# Health and models (no auth)
14
14
python examples/01_live_api_smoke.py
15
15
16
-
#Exact cache: identical requests; second = cache hit
17
-
python examples/07_cache_demo.py
16
+
#Auth and identity
17
+
python examples/00_auth_identity.py
18
18
19
-
# Semantic cache: similar prompts; second may = cache hit (Vertex AI + Firestore)
20
-
python examples/08_semantic_cache_demo.py
21
-
22
-
# Run all capability examples (images, video, usage, providers, etc.)
19
+
# Run all examples (requires API key; generation steps incur cost)
23
20
python examples/run_all_capabilities.py
24
21
```
25
22
26
-
**Regenerate sample outputs (Istanbul-themed images + video + GIF):**
23
+
**Run with a credentials file (e.g. `sifreler` in repo root):**
27
24
28
25
```bash
29
-
cd examples
30
-
python fetch_sample_outputs.py # images + video (waits for video when async)
31
-
python make_video_and_gif.py # video + GIF (or use --mp4 path to convert only)
32
-
python create_placeholder_video.py # placeholder istanbul.mp4 + .gif without API
26
+
python examples/run_with_sifreler.py
27
+
python examples/run_with_sifreler.py 04_videos_all_providers.py # single example
33
28
```
34
29
30
+
**Low-cost run (no image/video generation):**`00_smoke_sdk`, `01_live_api_smoke`, `00_auth_identity`, `01_models_catalog`, `05_usage_history_verify`, `06_provider_balances`, `09_provider_keys`, `10_api_keys`, `11_billing_readonly`. See [examples/README.md](examples/README.md) for the full table and sample outputs.
31
+
35
32
Base URL defaults to `https://visgateai.com/api/v1`. Override with `VISGATE_BASE_URL` for staging or local.
36
33
37
34
## Installation
@@ -207,6 +204,7 @@ result = client.videos.generate(
207
204
prompt="a cat walking",
208
205
image_url=None, # Optional, image URL to animate
209
206
duration_seconds=5.0, # Optional, default 5.0
207
+
skip_gcs_upload=False, # Set True to return provider URL directly (faster, avoids proxy timeouts)
@@ -224,16 +222,64 @@ result = await client.videos.generate(
224
222
### VideoResult Properties
225
223
226
224
-`id` (str): Request ID
227
-
-`video_url` (str | None): Generated video URL
225
+
-`video_url` (str | None): Generated video URL (may be ``None`` if generation failed or still processing)
228
226
-`model` (str): Model identifier used
229
-
-`provider` (str): Provider name
227
+
-`provider` (str): Provider name (e.g. ``"fal"``, ``"replicate"``, ``"runway"``)
230
228
-`cost` (float): Cost in USD
231
229
-`cache_hit` (bool): Whether the result was served from cache
232
-
-`provider_cost_avoided_micro` (int | None): When `cache_hit` is true, provider cost avoided in micro-USD (1e-6 USD). Omitted on cache miss.
230
+
-`provider_cost_avoided_micro` (int | None): When `cache_hit` is true, provider cost avoided in micro-USD. Omitted on cache miss.
233
231
-`latency_ms` (int | None): Request latency in milliseconds
234
232
-`created_at` (datetime): Creation timestamp
235
233
236
-
**Note:** Video generation may be asynchronous. Check `video_url` to see if the video is ready. You can convert the downloaded MP4 to a GIF for previews (e.g. `examples/make_video_and_gif.py` or `--mp4 path/to/video.mp4`).
234
+
**Note:** Video generation can take a minute or more. Use `skip_gcs_upload=True` to get the provider URL directly and avoid proxy timeouts. For non-blocking flow, use `wait=False` and poll via the Requests resource (see below).
235
+
236
+
### Async 202 + poll (wait=False)
237
+
238
+
For long-running video or image generation, use `wait=False` to get a 202 response and a `GenerationRequest`; then poll until complete:
239
+
240
+
```python
241
+
req = client.videos.generate(
242
+
model="fal-ai/veo3",
243
+
prompt="Cinematic drone over Istanbul",
244
+
duration_seconds=5.0,
245
+
wait=False,
246
+
)
247
+
# req has .request_id and .status ("accepted", "processing", "completed", "failed")
248
+
result = req.wait() # blocks until completed, returns VideoResult
249
+
print(result.video_url)
250
+
251
+
# Or poll manually
252
+
status = client.requests.get(req.request_id, wait=True)
253
+
# status.result is VideoResult when status.status == "completed"
254
+
```
255
+
256
+
## Requests Resource
257
+
258
+
Poll async generation status (202 flow for videos/images).
259
+
260
+
### Sync
261
+
262
+
```python
263
+
req = client.requests.get(request_id) # current status
264
+
req = client.requests.get(request_id, wait=True) # block until completed
265
+
# req: RequestStatusResult with .request_id, .status, .result (VideoResult/ImageResult when completed)
|`VisgateError`| 404, 500, etc. | e.g. 404 + ``MODEL_NOT_FOUND`` for unsupported model; other API errors |
318
364
319
365
### Exception Properties
320
366
@@ -431,10 +477,10 @@ API traffic is over HTTPS. Provider keys (BYOK) are encrypted at rest; account a
431
477
432
478
## Sample outputs (Istanbul theme)
433
479
434
-
All example scripts use Istanbul-themed prompts (Bosphorus, minarets, golden hour, Galata Tower, etc.). Generated assets are under`examples/sample_outputs/`: images (e.g. `generate_unified.jpg`, `sunset_istanbul.jpg`, `galata_tower.jpg`, `bosphorus_night.jpg`), cache demos, and video `istanbul.mp4`plus `istanbul.gif` (video converted to GIF for previews).
480
+
Example scripts use Istanbul-themed prompts (Bosphorus, Galata Tower, golden hour). Generated assets are in`examples/sample_outputs/`: images (`generate_unified.jpg`, `sunset_istanbul.jpg`, `galata_tower.jpg`, `bosphorus_night.jpg`), cache demos (`cache_demo.jpg`, `semantic_exact.jpg`, `semantic_similar.jpg`), and video `istanbul.mp4`with preview `istanbul.gif`. See [examples/README.md](examples/README.md) for the output gallery and provider counts.
0 commit comments