videogen 2.2.1__tar.gz → 2.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. {videogen-2.2.1 → videogen-2.6.0}/PKG-INFO +67 -34
  2. videogen-2.6.0/README.md +321 -0
  3. {videogen-2.2.1 → videogen-2.6.0}/pyproject.toml +1 -1
  4. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/__init__.py +8 -0
  5. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/_http.py +17 -1
  6. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/async_poll_executed_tool.py +2 -0
  7. videogen-2.6.0/src/videogen/async_poll_file_url_import.py +38 -0
  8. videogen-2.6.0/src/videogen/async_poll_video_edits.py +49 -0
  9. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/async_poll_workflow_run.py +2 -0
  10. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/async_upload_file.py +10 -3
  11. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/client.py +22 -0
  12. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/errors.py +3 -0
  13. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/poll_executed_tool.py +3 -1
  14. videogen-2.6.0/src/videogen/poll_file_url_import.py +38 -0
  15. videogen-2.6.0/src/videogen/poll_video_edits.py +72 -0
  16. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/poll_workflow_run.py +3 -1
  17. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/resources/__init__.py +6 -0
  18. videogen-2.6.0/src/videogen/resources/billing.py +191 -0
  19. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/resources/files.py +125 -0
  20. videogen-2.6.0/src/videogen/resources/models.py +87 -0
  21. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/resources/projects.py +294 -2
  22. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/resources/tools.py +68 -0
  23. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/resources/workflows.py +144 -0
  24. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/upload_file.py +10 -3
  25. {videogen-2.2.1 → videogen-2.6.0}/src/videogen.egg-info/PKG-INFO +67 -34
  26. {videogen-2.2.1 → videogen-2.6.0}/src/videogen.egg-info/SOURCES.txt +10 -1
  27. videogen-2.6.0/tests/test_billing.py +243 -0
  28. videogen-2.6.0/tests/test_models.py +48 -0
  29. videogen-2.6.0/tests/test_projects.py +50 -0
  30. videogen-2.2.1/README.md +0 -288
  31. {videogen-2.2.1 → videogen-2.6.0}/setup.cfg +0 -0
  32. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/async_create_public_preview.py +0 -0
  33. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/async_download_file.py +0 -0
  34. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/async_get_hydrated_file.py +0 -0
  35. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/async_poll_assistant_message.py +0 -0
  36. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/async_poll_project_export.py +0 -0
  37. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/async_poll_public_preview.py +0 -0
  38. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/async_poll_remix_actions.py +0 -0
  39. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/async_poll_timeline_interchange.py +0 -0
  40. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/create_public_preview.py +0 -0
  41. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/download_file.py +0 -0
  42. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/get_hydrated_file.py +0 -0
  43. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/poll_assistant_message.py +0 -0
  44. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/poll_helpers.py +0 -0
  45. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/poll_project_export.py +0 -0
  46. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/poll_public_preview.py +0 -0
  47. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/poll_remix_actions.py +0 -0
  48. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/poll_timeline_interchange.py +0 -0
  49. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/py.typed +0 -0
  50. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/resources/account.py +0 -0
  51. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/resources/assistant.py +0 -0
  52. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/resources/entities.py +0 -0
  53. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/resources/resources.py +0 -0
  54. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/resources/text.py +0 -0
  55. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/resources/webhooks.py +0 -0
  56. {videogen-2.2.1 → videogen-2.6.0}/src/videogen/verify_webhook_signature.py +0 -0
  57. {videogen-2.2.1 → videogen-2.6.0}/src/videogen.egg-info/dependency_links.txt +0 -0
  58. {videogen-2.2.1 → videogen-2.6.0}/src/videogen.egg-info/requires.txt +0 -0
  59. {videogen-2.2.1 → videogen-2.6.0}/src/videogen.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: videogen
3
- Version: 2.2.1
3
+ Version: 2.6.0
4
4
  Summary: Official Python SDK for the VideoGen API
5
5
  Author-email: VideoGen <support@videogen.io>
6
6
  License: MIT
@@ -52,7 +52,7 @@ run = vg.workflows.script_to_video_and_wait(
52
52
  },
53
53
  quality="HIGH",
54
54
  auto_export=True,
55
- remix_actions=[
55
+ video_edits=[
56
56
  {"type": "ENABLE_CAPTIONS"},
57
57
  {
58
58
  "type": "CONVERT_IMAGES_TO_VIDEOS",
@@ -83,7 +83,7 @@ run = await vg.workflows.script_to_video_and_wait(
83
83
  },
84
84
  quality="HIGH",
85
85
  auto_export=True,
86
- remix_actions=[
86
+ video_edits=[
87
87
  {"type": "ENABLE_CAPTIONS"},
88
88
  {
89
89
  "type": "CONVERT_IMAGES_TO_VIDEOS",
@@ -98,18 +98,19 @@ print(run.download_url)
98
98
 
99
99
  ## What you can do
100
100
 
101
- | Area | Client surface | Typical entry points |
102
- | --- | --- | --- |
103
- | Account | `vg.account` | `get_me` |
104
- | Workflows | `vg.workflows` | `script_to_video_and_wait`, `prompt_to_video_clip_and_wait`, `voiceover_to_video_and_wait`, `slideshow_to_video_and_wait` |
105
- | Tools | `vg.tools` | `generate_image_and_wait`, `generate_video_clip_and_wait`, `text_to_speech_and_wait`, … |
106
- | Files | helpers on `vg` | `upload_file`, `download_file`, `create_public_preview` |
107
- | Projects | `vg.projects` | `export_and_wait`, `remix_and_wait`, `create_timeline_interchange_and_wait` |
108
- | Assistant | `vg.assistant` | `start_assistant_chat_and_wait`, `send_assistant_message_and_wait` |
109
- | Entities | `vg.entities` | `create_entity`, `list_entities`, `add_entity_reference` |
110
- | Text | `vg.text` | `generate_text` |
111
- | Catalog | `vg.resources` | `list_tts_voices`, `list_languages` |
112
- | Webhooks | `vg.webhooks` + helper | `create_webhook_endpoint`, `verify_webhook_signature` |
101
+ | Area | Client surface | Typical entry points |
102
+ | --------- | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
103
+ | Account | `vg.account` | `get_me` |
104
+ | Billing | `vg.billing` | `get_billing_account`, `create_billing_order`, `get_billing_order`, `complete_billing_order`, `cancel_billing_order`, `request_billing_refund` |
105
+ | Workflows | `vg.workflows` | `script_to_video_and_wait`, `prompt_to_video_clip_and_wait`, `voiceover_to_video_and_wait`, `slideshow_to_video_and_wait`, `video_to_video_and_wait`, `translate_video_and_wait` |
106
+ | Tools | `vg.tools` | `generate_image_and_wait`, `generate_video_clip_and_wait`, `text_to_speech_and_wait`, … |
107
+ | Files | helpers on `vg` | `upload_file`, `download_file`, `create_public_preview` |
108
+ | Projects | `vg.projects` | `export_and_wait`, `start_video_edits_and_wait`, `create_timeline_interchange_and_wait` |
109
+ | Assistant | `vg.assistant` | `start_assistant_chat_and_wait`, `send_assistant_message_and_wait` |
110
+ | Entities | `vg.entities` | `create_entity`, `list_entities`, `add_entity_reference` |
111
+ | Text | `vg.text` | `generate_text` |
112
+ | Catalog | `vg.resources` | `list_tts_voices`, `list_languages` |
113
+ | Webhooks | `vg.webhooks` + helper | `create_webhook_endpoint`, `verify_webhook_signature` |
113
114
 
114
115
  Prefer `*_and_wait` (or the matching `poll_*` / `async_poll_*` helper) for anything asynchronous. Thin REST methods match OpenAPI `operationId`s (snake_case).
115
116
 
@@ -119,6 +120,35 @@ Prefer `*_and_wait` (or the matching `poll_*` / `async_poll_*` helper) for anyth
119
120
  - **Requests:** pass snake_case kwargs (and nested dict keys). The client serializes body/query keys to camelCase for the wire.
120
121
  - **Responses:** JSON objects are converted recursively to snake_case keys (`tool_execution_id`, `workflow_run_id`, `has_more`).
121
122
 
123
+ ## Billing
124
+
125
+ Billing requires explicit account access granted in VideoGen. Quote a one-time credit purchase before requesting approval:
126
+
127
+ ```python
128
+ from uuid import uuid4
129
+
130
+ account = vg.billing.get_billing_account()
131
+ order = vg.billing.create_billing_order(order_id=str(uuid4()), credits=2000)
132
+ print(order["total_minor"], order["currency"], order["refund_terms"])
133
+ ```
134
+
135
+ Reuse the same order UUID for an identical quote retry. Show the complete order terms to the user. After the user approves those exact terms, a compatible wallet supplies a scoped payment token through a secure channel:
136
+
137
+ ```python
138
+ result = vg.billing.complete_billing_order(
139
+ order_id=order["order_id"],
140
+ revision=order["revision"],
141
+ idempotency_key=approved_request_key,
142
+ payment_token=wallet_payment_token,
143
+ )
144
+ ```
145
+
146
+ The SDK sends that token only in the `Stripe-Shared-Payment-Token` header, separately from bearer authentication. Keep it out of prompts, URLs, logs, and saved order data. Completion makes one request with no automatic retries. On an uncertain response, read `get_billing_order(order_id=order["order_id"])` before retrying with the same order, revision, idempotency key, and credential.
147
+
148
+ Payment and credit fulfillment have separate states. Inspect `result["state"]`; a processing payment or pending fulfillment is not a completed credit grant. `cancel_billing_order` cancels an unpaid order; `request_billing_refund` records a support-reviewed request and does not complete a refund. Async clients expose the same methods under `await vg.billing...`. Billing methods accept `cancel_event` or `options={"cancel_event": event}`.
149
+
150
+ When `result["verification_url"]` is present, the purchaser can open that secure VideoGen continuation and sign in on the same team to complete verification. It is not a new checkout. Account responses may include `purchase_restriction` and a `credit_pack` dict with `minimum_credits`, `step_credits`, and `maximum_credits`.
151
+
122
152
  ## Workflows
123
153
 
124
154
  Script to video (above) is the usual path. Prompt to video clip builds a single clip from a prompt:
@@ -136,7 +166,7 @@ run = vg.workflows.prompt_to_video_clip_and_wait(
136
166
  print(run.download_url)
137
167
  ```
138
168
 
139
- Other workflow starters: `voiceover_to_video_and_wait` (uploaded audio `file_id`), `slideshow_to_video_and_wait` (deck `file_id`).
169
+ Other workflow starters: `voiceover_to_video_and_wait` (uploaded audio `file_id`), `slideshow_to_video_and_wait` (deck `file_id`), `video_to_video_and_wait` (restyles an uploaded `video_file_id` or a public `video_url` from a `prompt`), `translate_video_and_wait` (translates an uploaded `video_file_id` into each of `output_languages`, one editable video per language; read each language's `editable_video_id` from the run's `outputs` and pass it to `export_and_wait`).
140
170
 
141
171
  ## Tools
142
172
 
@@ -182,7 +212,7 @@ vg.download_file(uploaded["file_id"], output_path="output.mp4")
182
212
 
183
213
  ## Projects
184
214
 
185
- Export a finished workflow project, or apply remix actions later:
215
+ Export a finished workflow project, or apply video edits later:
186
216
 
187
217
  ```python
188
218
  import os
@@ -195,14 +225,15 @@ project_id = "vg_proj_..."
195
225
  exported = vg.projects.export_and_wait(project_id=project_id, quality="HIGH")
196
226
  print(exported["status"], exported.get("export_file_id"))
197
227
 
198
- remix = vg.projects.remix_and_wait(
228
+ edits = vg.projects.start_video_edits_and_wait(
199
229
  project_id=project_id,
200
- remix_actions=[
230
+ editable_video_id="editable-video-id",
231
+ video_edits=[
201
232
  {"type": "ENABLE_CAPTIONS"},
202
233
  {"type": "ADD_TRANSITIONS"},
203
234
  ],
204
235
  )
205
- print(remix)
236
+ print(edits)
206
237
  ```
207
238
 
208
239
  ## Assistant
@@ -281,20 +312,22 @@ Register endpoints with `vg.webhooks.create_webhook_endpoint`. Signatures follow
281
312
 
282
313
  Exported as module functions and bound on the client:
283
314
 
284
- | Helper | Purpose |
285
- | --- | --- |
286
- | `poll_assistant_message` / `async_poll_assistant_message` | Poll an assistant message to a terminal status |
287
- | `poll_executed_tool` / `async_poll_executed_tool` | Poll a tool execution to a terminal status |
288
- | `poll_workflow_run` / `async_poll_workflow_run` | Poll a workflow run |
289
- | `poll_project_export` / `async_poll_project_export` | Poll a project export |
290
- | `poll_timeline_interchange` / `async_poll_timeline_interchange` | Poll a timeline interchange job |
291
- | `poll_remix_actions` / `async_poll_remix_actions` | Poll remix actions until all are terminal |
292
- | `poll_public_preview` / `async_poll_public_preview` | Poll until a public preview URL is ready |
293
- | `upload_file` / `async_upload_file` | Presign, PUT bytes, poll until the file is ready |
294
- | `get_hydrated_file` / `async_get_hydrated_file` | Hydrate signed source URLs |
295
- | `download_file` / `async_download_file` | Hydrate then download bytes (optional path) |
296
- | `create_public_preview` / `async_create_public_preview` | Enable + poll public preview |
297
- | `verify_webhook_signature` | Verify Standard Webhooks and return the event dict |
315
+ | Helper | Purpose |
316
+ | --------------------------------------------------------------- | ----------------------------------------------------------------- |
317
+ | `poll_assistant_message` / `async_poll_assistant_message` | Poll an assistant message to a terminal status |
318
+ | `poll_executed_tool` / `async_poll_executed_tool` | Poll a tool execution to a terminal status or `awaiting_approval` |
319
+ | `poll_workflow_run` / `async_poll_workflow_run` | Poll a workflow run to a terminal status or `awaiting_approval` |
320
+ | `poll_project_export` / `async_poll_project_export` | Poll a project export |
321
+ | `poll_timeline_interchange` / `async_poll_timeline_interchange` | Poll a timeline interchange job |
322
+ | `poll_video_edits` / `async_poll_video_edits` | Poll video edits until the requested edits are terminal |
323
+ | `poll_public_preview` / `async_poll_public_preview` | Poll until a public preview URL is ready |
324
+ | `upload_file` / `async_upload_file` | Presign, PUT bytes, poll until the file is ready |
325
+ | `get_hydrated_file` / `async_get_hydrated_file` | Hydrate signed source URLs |
326
+ | `download_file` / `async_download_file` | Hydrate then download bytes (optional path) |
327
+ | `create_public_preview` / `async_create_public_preview` | Enable + poll public preview |
328
+ | `verify_webhook_signature` | Verify Standard Webhooks and return the event dict |
329
+
330
+ Workflow and tool pollers, including their `*_and_wait` wrappers, return `awaiting_approval` unchanged without throwing, even with the default `throw_on_failure=True`. This status means the result needs approval; it does not mean the operation succeeded. Check `status` before using the result as a completed operation.
298
331
 
299
332
  Cancellation: pass `cancel_event=threading.Event()` (sync) or `asyncio.Event()` (async) to poll helpers and thin request methods. Setting the event raises `PollCancelledError`.
300
333
 
@@ -0,0 +1,321 @@
1
+ # VideoGen Python SDK
2
+
3
+ Official Python client for the [VideoGen API](https://docs.videogen.io).
4
+
5
+ Package: `videogen` (PyPI). Generate full videos from scripts, voiceovers, or slideshows, run media tools, manage files and projects, chat with the AI assistant, and verify webhooks.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pip install videogen
11
+ ```
12
+
13
+ Default base URL: `https://api.videogen.io`.
14
+
15
+ ## Quick start
16
+
17
+ ```python
18
+ import os
19
+ from videogen import VideoGen
20
+
21
+ vg = VideoGen(api_key=os.environ["VIDEOGEN_API_KEY"])
22
+
23
+ me = vg.account.get_me()
24
+ print(me["email"])
25
+
26
+ run = vg.workflows.script_to_video_and_wait(
27
+ script="Stay hydrated for better focus and energy.",
28
+ visual_style={
29
+ "type": "AI_IMAGE",
30
+ "ai_style": "Loose watercolor illustration, visible brushstrokes, soft color bleeds, paper texture, muted palette. A clear uncluttered subject centered in the frame, occupying only the middle half of the image, with generous empty margins on all four sides, no background clutter.",
31
+ },
32
+ quality="HIGH",
33
+ auto_export=True,
34
+ video_edits=[
35
+ {"type": "ENABLE_CAPTIONS"},
36
+ {
37
+ "type": "CONVERT_IMAGES_TO_VIDEOS",
38
+ "motion_prompt": "slow cinematic push-in",
39
+ "mute_output_videos": True,
40
+ "quality": "HIGH",
41
+ },
42
+ ],
43
+ )
44
+ print(run.download_url)
45
+ ```
46
+
47
+ Omit `api_key` to read `VIDEOGEN_API_KEY` from the environment.
48
+
49
+ ### Async client
50
+
51
+ ```python
52
+ import os
53
+ from videogen import AsyncVideoGen
54
+
55
+ vg = AsyncVideoGen(api_key=os.environ["VIDEOGEN_API_KEY"])
56
+
57
+ run = await vg.workflows.script_to_video_and_wait(
58
+ script="Stay hydrated for better focus and energy.",
59
+ visual_style={
60
+ "type": "AI_IMAGE",
61
+ "ai_style": "Loose watercolor illustration, visible brushstrokes, soft color bleeds, paper texture, muted palette. A clear uncluttered subject centered in the frame, occupying only the middle half of the image, with generous empty margins on all four sides, no background clutter.",
62
+ },
63
+ quality="HIGH",
64
+ auto_export=True,
65
+ video_edits=[
66
+ {"type": "ENABLE_CAPTIONS"},
67
+ {
68
+ "type": "CONVERT_IMAGES_TO_VIDEOS",
69
+ "motion_prompt": "slow cinematic push-in",
70
+ "mute_output_videos": True,
71
+ "quality": "HIGH",
72
+ },
73
+ ],
74
+ )
75
+ print(run.download_url)
76
+ ```
77
+
78
+ ## What you can do
79
+
80
+ | Area | Client surface | Typical entry points |
81
+ | --------- | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
82
+ | Account | `vg.account` | `get_me` |
83
+ | Billing | `vg.billing` | `get_billing_account`, `create_billing_order`, `get_billing_order`, `complete_billing_order`, `cancel_billing_order`, `request_billing_refund` |
84
+ | Workflows | `vg.workflows` | `script_to_video_and_wait`, `prompt_to_video_clip_and_wait`, `voiceover_to_video_and_wait`, `slideshow_to_video_and_wait`, `video_to_video_and_wait`, `translate_video_and_wait` |
85
+ | Tools | `vg.tools` | `generate_image_and_wait`, `generate_video_clip_and_wait`, `text_to_speech_and_wait`, … |
86
+ | Files | helpers on `vg` | `upload_file`, `download_file`, `create_public_preview` |
87
+ | Projects | `vg.projects` | `export_and_wait`, `start_video_edits_and_wait`, `create_timeline_interchange_and_wait` |
88
+ | Assistant | `vg.assistant` | `start_assistant_chat_and_wait`, `send_assistant_message_and_wait` |
89
+ | Entities | `vg.entities` | `create_entity`, `list_entities`, `add_entity_reference` |
90
+ | Text | `vg.text` | `generate_text` |
91
+ | Catalog | `vg.resources` | `list_tts_voices`, `list_languages` |
92
+ | Webhooks | `vg.webhooks` + helper | `create_webhook_endpoint`, `verify_webhook_signature` |
93
+
94
+ Prefer `*_and_wait` (or the matching `poll_*` / `async_poll_*` helper) for anything asynchronous. Thin REST methods match OpenAPI `operationId`s (snake_case).
95
+
96
+ ## Naming and JSON
97
+
98
+ - **Methods:** snake_case (`script_to_video`, `get_tool_execution_info`).
99
+ - **Requests:** pass snake_case kwargs (and nested dict keys). The client serializes body/query keys to camelCase for the wire.
100
+ - **Responses:** JSON objects are converted recursively to snake_case keys (`tool_execution_id`, `workflow_run_id`, `has_more`).
101
+
102
+ ## Billing
103
+
104
+ Billing requires explicit account access granted in VideoGen. Quote a one-time credit purchase before requesting approval:
105
+
106
+ ```python
107
+ from uuid import uuid4
108
+
109
+ account = vg.billing.get_billing_account()
110
+ order = vg.billing.create_billing_order(order_id=str(uuid4()), credits=2000)
111
+ print(order["total_minor"], order["currency"], order["refund_terms"])
112
+ ```
113
+
114
+ Reuse the same order UUID for an identical quote retry. Show the complete order terms to the user. After the user approves those exact terms, a compatible wallet supplies a scoped payment token through a secure channel:
115
+
116
+ ```python
117
+ result = vg.billing.complete_billing_order(
118
+ order_id=order["order_id"],
119
+ revision=order["revision"],
120
+ idempotency_key=approved_request_key,
121
+ payment_token=wallet_payment_token,
122
+ )
123
+ ```
124
+
125
+ The SDK sends that token only in the `Stripe-Shared-Payment-Token` header, separately from bearer authentication. Keep it out of prompts, URLs, logs, and saved order data. Completion makes one request with no automatic retries. On an uncertain response, read `get_billing_order(order_id=order["order_id"])` before retrying with the same order, revision, idempotency key, and credential.
126
+
127
+ Payment and credit fulfillment have separate states. Inspect `result["state"]`; a processing payment or pending fulfillment is not a completed credit grant. `cancel_billing_order` cancels an unpaid order; `request_billing_refund` records a support-reviewed request and does not complete a refund. Async clients expose the same methods under `await vg.billing...`. Billing methods accept `cancel_event` or `options={"cancel_event": event}`.
128
+
129
+ When `result["verification_url"]` is present, the purchaser can open that secure VideoGen continuation and sign in on the same team to complete verification. It is not a new checkout. Account responses may include `purchase_restriction` and a `credit_pack` dict with `minimum_credits`, `step_credits`, and `maximum_credits`.
130
+
131
+ ## Workflows
132
+
133
+ Script to video (above) is the usual path. Prompt to video clip builds a single clip from a prompt:
134
+
135
+ ```python
136
+ import os
137
+ from videogen import VideoGen
138
+
139
+ vg = VideoGen(api_key=os.environ["VIDEOGEN_API_KEY"])
140
+
141
+ run = vg.workflows.prompt_to_video_clip_and_wait(
142
+ prompt="A glass of water catching morning light on a kitchen counter, slow push-in",
143
+ quality="HIGH",
144
+ )
145
+ print(run.download_url)
146
+ ```
147
+
148
+ Other workflow starters: `voiceover_to_video_and_wait` (uploaded audio `file_id`), `slideshow_to_video_and_wait` (deck `file_id`), `video_to_video_and_wait` (restyles an uploaded `video_file_id` or a public `video_url` from a `prompt`), `translate_video_and_wait` (translates an uploaded `video_file_id` into each of `output_languages`, one editable video per language; read each language's `editable_video_id` from the run's `outputs` and pass it to `export_and_wait`).
149
+
150
+ ## Tools
151
+
152
+ ```python
153
+ import os
154
+ from videogen import VideoGen
155
+
156
+ vg = VideoGen(api_key=os.environ["VIDEOGEN_API_KEY"])
157
+
158
+ execution = vg.tools.generate_image_and_wait(
159
+ prompt="A sunset over a calm ocean, cinematic lighting",
160
+ quality="HIGH",
161
+ )
162
+
163
+ results = execution.get("results") or []
164
+ file_id = results[0]["file_id"] if results else None
165
+ if file_id is None:
166
+ raise RuntimeError("Expected a generated file id")
167
+
168
+ preview = vg.create_public_preview(file_id)
169
+ print(execution["status"], preview)
170
+ ```
171
+
172
+ The same `*_and_wait` pattern exists for video clips, motion graphics, TTS, music, sound effects, avatar, upscale, background removal, and more under `vg.tools`.
173
+
174
+ For avatar video, call `generate_avatar_and_wait` with `audio_file_id` and an ACTOR entity as `actor_entity_id`. You may set `avatar_quality` to `LOW`, `STANDARD`, `HIGH`, or `MAX`. Script-to-video, voiceover-to-video, slideshow-to-video, and `CHANGE_NARRATOR` accept the same optional actor fields.
175
+
176
+ ## Files
177
+
178
+ ```python
179
+ import os
180
+ from videogen import VideoGen
181
+
182
+ vg = VideoGen(api_key=os.environ["VIDEOGEN_API_KEY"])
183
+
184
+ with open("input.mp4", "rb") as f:
185
+ uploaded = vg.upload_file(f, display_name="input.mp4", type="VIDEO")
186
+
187
+ print(uploaded["file_id"])
188
+
189
+ vg.download_file(uploaded["file_id"], output_path="output.mp4")
190
+ ```
191
+
192
+ ## Projects
193
+
194
+ Export a finished workflow project, or apply video edits later:
195
+
196
+ ```python
197
+ import os
198
+ from videogen import VideoGen
199
+
200
+ vg = VideoGen(api_key=os.environ["VIDEOGEN_API_KEY"])
201
+
202
+ project_id = "vg_proj_..."
203
+
204
+ exported = vg.projects.export_and_wait(project_id=project_id, quality="HIGH")
205
+ print(exported["status"], exported.get("export_file_id"))
206
+
207
+ edits = vg.projects.start_video_edits_and_wait(
208
+ project_id=project_id,
209
+ editable_video_id="editable-video-id",
210
+ video_edits=[
211
+ {"type": "ENABLE_CAPTIONS"},
212
+ {"type": "ADD_TRANSITIONS"},
213
+ ],
214
+ )
215
+ print(edits)
216
+ ```
217
+
218
+ ## Assistant
219
+
220
+ ```python
221
+ import os
222
+ from videogen import VideoGen
223
+
224
+ vg = VideoGen(api_key=os.environ["VIDEOGEN_API_KEY"])
225
+
226
+ started = vg.assistant.start_assistant_chat(
227
+ message="Draft a 20-second script about morning hydration.",
228
+ )
229
+ message = vg.poll_assistant_message(started["message_id"])
230
+
231
+ print(message["status"], started.get("assistant_id"), started.get("project_id"))
232
+ ```
233
+
234
+ Or use `start_assistant_chat_and_wait` when you only need the terminal message. Continue with `send_assistant_message_and_wait` / `act_on_assistant_action_and_wait` on the same `assistant_id`.
235
+
236
+ ## Entities
237
+
238
+ Reusable actors, products, and visual styles for consistent generation:
239
+
240
+ ```python
241
+ import os
242
+ from videogen import VideoGen
243
+
244
+ vg = VideoGen(api_key=os.environ["VIDEOGEN_API_KEY"])
245
+
246
+ entity = vg.entities.create_entity(
247
+ entity_type="ACTOR",
248
+ name="Alex",
249
+ description="Friendly narrator in casual clothes",
250
+ )
251
+ print(entity["entity_id"])
252
+ ```
253
+
254
+ Attach reference images with `add_entity_reference`, then pass entity ids into workflows.
255
+
256
+ ## Text
257
+
258
+ ```python
259
+ import os
260
+ from videogen import VideoGen
261
+
262
+ vg = VideoGen(api_key=os.environ["VIDEOGEN_API_KEY"])
263
+
264
+ result = vg.text.generate_text(
265
+ prompt="Write a one-sentence hook for a hydration tip video.",
266
+ )
267
+ print(result["text"])
268
+ ```
269
+
270
+ ## Webhooks
271
+
272
+ ```python
273
+ import os
274
+ from videogen import verify_webhook_signature
275
+
276
+ event = verify_webhook_signature(
277
+ raw_body="...", # raw request body string
278
+ headers={
279
+ "webhook-id": "...",
280
+ "webhook-timestamp": "...",
281
+ "webhook-signature": "...",
282
+ },
283
+ secret=os.environ.get("VIDEOGEN_WEBHOOK_SECRET", ""),
284
+ )
285
+ print(event)
286
+ ```
287
+
288
+ Register endpoints with `vg.webhooks.create_webhook_endpoint`. Signatures follow the Standard Webhooks scheme.
289
+
290
+ ## Helpers
291
+
292
+ Exported as module functions and bound on the client:
293
+
294
+ | Helper | Purpose |
295
+ | --------------------------------------------------------------- | ----------------------------------------------------------------- |
296
+ | `poll_assistant_message` / `async_poll_assistant_message` | Poll an assistant message to a terminal status |
297
+ | `poll_executed_tool` / `async_poll_executed_tool` | Poll a tool execution to a terminal status or `awaiting_approval` |
298
+ | `poll_workflow_run` / `async_poll_workflow_run` | Poll a workflow run to a terminal status or `awaiting_approval` |
299
+ | `poll_project_export` / `async_poll_project_export` | Poll a project export |
300
+ | `poll_timeline_interchange` / `async_poll_timeline_interchange` | Poll a timeline interchange job |
301
+ | `poll_video_edits` / `async_poll_video_edits` | Poll video edits until the requested edits are terminal |
302
+ | `poll_public_preview` / `async_poll_public_preview` | Poll until a public preview URL is ready |
303
+ | `upload_file` / `async_upload_file` | Presign, PUT bytes, poll until the file is ready |
304
+ | `get_hydrated_file` / `async_get_hydrated_file` | Hydrate signed source URLs |
305
+ | `download_file` / `async_download_file` | Hydrate then download bytes (optional path) |
306
+ | `create_public_preview` / `async_create_public_preview` | Enable + poll public preview |
307
+ | `verify_webhook_signature` | Verify Standard Webhooks and return the event dict |
308
+
309
+ Workflow and tool pollers, including their `*_and_wait` wrappers, return `awaiting_approval` unchanged without throwing, even with the default `throw_on_failure=True`. This status means the result needs approval; it does not mean the operation succeeded. Check `status` before using the result as a completed operation.
310
+
311
+ Cancellation: pass `cancel_event=threading.Event()` (sync) or `asyncio.Event()` (async) to poll helpers and thin request methods. Setting the event raises `PollCancelledError`.
312
+
313
+ ## Errors
314
+
315
+ `VideoGenError` exposes `status`, `body`, and `request_id` (from `x-request-id` when present).
316
+
317
+ ## Docs
318
+
319
+ - [API documentation](https://docs.videogen.io)
320
+ - [PyPI: videogen](https://pypi.org/project/videogen/)
321
+ - [GitHub](https://github.com/video-gen/videogen-python-sdk)
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "videogen"
7
- version = "2.2.1"
7
+ version = "2.6.0"
8
8
  description = "Official Python SDK for the VideoGen API"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -9,8 +9,10 @@ from .async_download_file import async_download_file
9
9
  from .async_get_hydrated_file import async_get_hydrated_file
10
10
  from .async_poll_assistant_message import async_poll_assistant_message
11
11
  from .async_poll_executed_tool import async_poll_executed_tool
12
+ from .async_poll_file_url_import import async_poll_file_url_import
12
13
  from .async_poll_project_export import async_poll_project_export
13
14
  from .async_poll_public_preview import async_poll_public_preview
15
+ from .async_poll_video_edits import async_poll_video_edits
14
16
  from .async_poll_remix_actions import async_poll_remix_actions
15
17
  from .async_poll_timeline_interchange import async_poll_timeline_interchange
16
18
  from .async_poll_workflow_run import async_poll_workflow_run
@@ -22,8 +24,10 @@ from .errors import PollCancelledError, VideoGenError
22
24
  from .get_hydrated_file import get_hydrated_file
23
25
  from .poll_assistant_message import poll_assistant_message
24
26
  from .poll_executed_tool import poll_executed_tool
27
+ from .poll_file_url_import import poll_file_url_import
25
28
  from .poll_project_export import poll_project_export
26
29
  from .poll_public_preview import poll_public_preview
30
+ from .poll_video_edits import poll_video_edits
27
31
  from .poll_remix_actions import poll_remix_actions
28
32
  from .poll_timeline_interchange import poll_timeline_interchange
29
33
  from .poll_workflow_run import poll_workflow_run
@@ -40,8 +44,10 @@ __all__ = [
40
44
  "async_get_hydrated_file",
41
45
  "async_poll_assistant_message",
42
46
  "async_poll_executed_tool",
47
+ "async_poll_file_url_import",
43
48
  "async_poll_project_export",
44
49
  "async_poll_public_preview",
50
+ "async_poll_video_edits",
45
51
  "async_poll_remix_actions",
46
52
  "async_poll_timeline_interchange",
47
53
  "async_poll_workflow_run",
@@ -51,8 +57,10 @@ __all__ = [
51
57
  "get_hydrated_file",
52
58
  "poll_assistant_message",
53
59
  "poll_executed_tool",
60
+ "poll_file_url_import",
54
61
  "poll_project_export",
55
62
  "poll_public_preview",
63
+ "poll_video_edits",
56
64
  "poll_remix_actions",
57
65
  "poll_timeline_interchange",
58
66
  "poll_workflow_run",
@@ -1,5 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
+ from urllib.parse import quote
4
+
3
5
  import json
4
6
  import os
5
7
  import re
@@ -121,6 +123,8 @@ class SyncHttpClient:
121
123
  body: Any = None,
122
124
  cancel_event: Any = None,
123
125
  raw_response: bool = False,
126
+ payment_token: Optional[str] = None,
127
+ idempotency_key: Optional[str] = None,
124
128
  ) -> Any:
125
129
  _raise_if_cancelled(cancel_event)
126
130
 
@@ -130,6 +134,10 @@ class SyncHttpClient:
130
134
  "Accept": "application/json",
131
135
  "X-VideoGen-Client": self.client_id,
132
136
  }
137
+ if idempotency_key is not None:
138
+ headers["Idempotency-Key"] = idempotency_key
139
+ if payment_token is not None:
140
+ headers["Stripe-Shared-Payment-Token"] = payment_token
133
141
  params = to_wire_keys(dict(query)) if query else None
134
142
  if params is not None:
135
143
  params = {k: v for k, v in params.items() if v is not None}
@@ -162,6 +170,7 @@ class SyncHttpClient:
162
170
  status=response.status_code,
163
171
  body=to_python_keys(err_body) if isinstance(err_body, (dict, list)) else err_body,
164
172
  request_id=request_id,
173
+ retry_after=response.headers.get("retry-after"),
165
174
  )
166
175
 
167
176
  if raw_response:
@@ -220,6 +229,8 @@ class AsyncHttpClient:
220
229
  body: Any = None,
221
230
  cancel_event: Any = None,
222
231
  raw_response: bool = False,
232
+ payment_token: Optional[str] = None,
233
+ idempotency_key: Optional[str] = None,
223
234
  ) -> Any:
224
235
  _raise_if_cancelled(cancel_event)
225
236
 
@@ -229,6 +240,10 @@ class AsyncHttpClient:
229
240
  "Accept": "application/json",
230
241
  "X-VideoGen-Client": self.client_id,
231
242
  }
243
+ if idempotency_key is not None:
244
+ headers["Idempotency-Key"] = idempotency_key
245
+ if payment_token is not None:
246
+ headers["Stripe-Shared-Payment-Token"] = payment_token
232
247
  params = to_wire_keys(dict(query)) if query else None
233
248
  if params is not None:
234
249
  params = {k: v for k, v in params.items() if v is not None}
@@ -261,6 +276,7 @@ class AsyncHttpClient:
261
276
  status=response.status_code,
262
277
  body=to_python_keys(err_body) if isinstance(err_body, (dict, list)) else err_body,
263
278
  request_id=request_id,
279
+ retry_after=response.headers.get("retry-after"),
264
280
  )
265
281
 
266
282
  if raw_response:
@@ -318,5 +334,5 @@ def split_request_args(
318
334
  def format_path(path_template: str, path_values: Mapping[str, Any]) -> str:
319
335
  path = path_template
320
336
  for key, value in path_values.items():
321
- path = path.replace("{" + key + "}", str(value))
337
+ path = path.replace("{" + key + "}", quote(str(value), safe=""))
322
338
  return path
@@ -30,6 +30,8 @@ async def async_poll_executed_tool(
30
30
  tool_execution_id=tool_execution_id,
31
31
  cancel_event=cancel_event,
32
32
  )
33
+ if isinstance(executed, dict) and executed.get("status") == "awaiting_approval":
34
+ return executed
33
35
  if isinstance(executed, dict) and executed.get("status") in TERMINAL_STATUSES:
34
36
  raise_if_failed(executed, throw_on_failure=throw_on_failure, kind="Tool execution")
35
37
  return executed
@@ -0,0 +1,38 @@
1
+ from __future__ import annotations
2
+
3
+ import time
4
+ from typing import Any, Optional
5
+
6
+ from .poll_helpers import (
7
+ TERMINAL_STATUSES,
8
+ async_poll_sleep,
9
+ ensure_within_timeout,
10
+ poll_raise_if_cancelled,
11
+ raise_if_failed,
12
+ )
13
+
14
+
15
+ async def async_poll_file_url_import(
16
+ client: Any,
17
+ file_import_id: str,
18
+ *,
19
+ poll_interval_ms: int = 1500,
20
+ timeout_ms: Optional[int] = 3_600_000,
21
+ throw_on_failure: bool = True,
22
+ cancel_event: Any = None,
23
+ ) -> dict:
24
+ """Async twin of `poll_file_url_import`."""
25
+ started_at = time.monotonic()
26
+ while True:
27
+ poll_raise_if_cancelled(cancel_event)
28
+ ensure_within_timeout(started_at=started_at, timeout_ms=timeout_ms)
29
+ file_url_import = await client.files.get_file_url_import(
30
+ file_import_id=file_import_id,
31
+ cancel_event=cancel_event,
32
+ )
33
+ if isinstance(file_url_import, dict) and file_url_import.get("status") in TERMINAL_STATUSES:
34
+ raise_if_failed(
35
+ file_url_import, throw_on_failure=throw_on_failure, kind="File import"
36
+ )
37
+ return file_url_import
38
+ await async_poll_sleep(poll_interval_ms, cancel_event)