videogen 2.5.3__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 (58) hide show
  1. {videogen-2.5.3 → videogen-2.6.0}/PKG-INFO +65 -34
  2. {videogen-2.5.3 → videogen-2.6.0}/README.md +64 -33
  3. {videogen-2.5.3 → videogen-2.6.0}/pyproject.toml +1 -1
  4. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/__init__.py +4 -0
  5. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/_http.py +17 -1
  6. videogen-2.6.0/src/videogen/async_poll_video_edits.py +49 -0
  7. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/client.py +14 -0
  8. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/errors.py +3 -0
  9. videogen-2.6.0/src/videogen/poll_video_edits.py +72 -0
  10. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/resources/__init__.py +6 -0
  11. videogen-2.6.0/src/videogen/resources/billing.py +191 -0
  12. videogen-2.6.0/src/videogen/resources/models.py +87 -0
  13. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/resources/projects.py +277 -0
  14. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/resources/tools.py +68 -0
  15. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/resources/workflows.py +72 -0
  16. {videogen-2.5.3 → videogen-2.6.0}/src/videogen.egg-info/PKG-INFO +65 -34
  17. {videogen-2.5.3 → videogen-2.6.0}/src/videogen.egg-info/SOURCES.txt +8 -1
  18. videogen-2.6.0/tests/test_billing.py +243 -0
  19. videogen-2.6.0/tests/test_models.py +48 -0
  20. videogen-2.6.0/tests/test_projects.py +50 -0
  21. {videogen-2.5.3 → videogen-2.6.0}/setup.cfg +0 -0
  22. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/async_create_public_preview.py +0 -0
  23. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/async_download_file.py +0 -0
  24. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/async_get_hydrated_file.py +0 -0
  25. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/async_poll_assistant_message.py +0 -0
  26. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/async_poll_executed_tool.py +0 -0
  27. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/async_poll_file_url_import.py +0 -0
  28. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/async_poll_project_export.py +0 -0
  29. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/async_poll_public_preview.py +0 -0
  30. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/async_poll_remix_actions.py +0 -0
  31. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/async_poll_timeline_interchange.py +0 -0
  32. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/async_poll_workflow_run.py +0 -0
  33. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/async_upload_file.py +0 -0
  34. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/create_public_preview.py +0 -0
  35. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/download_file.py +0 -0
  36. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/get_hydrated_file.py +0 -0
  37. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/poll_assistant_message.py +0 -0
  38. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/poll_executed_tool.py +0 -0
  39. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/poll_file_url_import.py +0 -0
  40. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/poll_helpers.py +0 -0
  41. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/poll_project_export.py +0 -0
  42. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/poll_public_preview.py +0 -0
  43. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/poll_remix_actions.py +0 -0
  44. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/poll_timeline_interchange.py +0 -0
  45. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/poll_workflow_run.py +0 -0
  46. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/py.typed +0 -0
  47. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/resources/account.py +0 -0
  48. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/resources/assistant.py +0 -0
  49. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/resources/entities.py +0 -0
  50. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/resources/files.py +0 -0
  51. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/resources/resources.py +0 -0
  52. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/resources/text.py +0 -0
  53. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/resources/webhooks.py +0 -0
  54. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/upload_file.py +0 -0
  55. {videogen-2.5.3 → videogen-2.6.0}/src/videogen/verify_webhook_signature.py +0 -0
  56. {videogen-2.5.3 → videogen-2.6.0}/src/videogen.egg-info/dependency_links.txt +0 -0
  57. {videogen-2.5.3 → videogen-2.6.0}/src/videogen.egg-info/requires.txt +0 -0
  58. {videogen-2.5.3 → 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.5.3
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`, `video_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`), `video_to_video_and_wait` (restyles an uploaded `video_file_id` or a public `video_url` from a `prompt`).
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,20 @@ 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 or `awaiting_approval` |
288
- | `poll_workflow_run` / `async_poll_workflow_run` | Poll a workflow run to a terminal status or `awaiting_approval` |
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 |
298
329
 
299
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.
300
331
 
@@ -31,7 +31,7 @@ run = vg.workflows.script_to_video_and_wait(
31
31
  },
32
32
  quality="HIGH",
33
33
  auto_export=True,
34
- remix_actions=[
34
+ video_edits=[
35
35
  {"type": "ENABLE_CAPTIONS"},
36
36
  {
37
37
  "type": "CONVERT_IMAGES_TO_VIDEOS",
@@ -62,7 +62,7 @@ run = await vg.workflows.script_to_video_and_wait(
62
62
  },
63
63
  quality="HIGH",
64
64
  auto_export=True,
65
- remix_actions=[
65
+ video_edits=[
66
66
  {"type": "ENABLE_CAPTIONS"},
67
67
  {
68
68
  "type": "CONVERT_IMAGES_TO_VIDEOS",
@@ -77,18 +77,19 @@ print(run.download_url)
77
77
 
78
78
  ## What you can do
79
79
 
80
- | Area | Client surface | Typical entry points |
81
- | --- | --- | --- |
82
- | Account | `vg.account` | `get_me` |
83
- | 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` |
84
- | Tools | `vg.tools` | `generate_image_and_wait`, `generate_video_clip_and_wait`, `text_to_speech_and_wait`, … |
85
- | Files | helpers on `vg` | `upload_file`, `download_file`, `create_public_preview` |
86
- | Projects | `vg.projects` | `export_and_wait`, `remix_and_wait`, `create_timeline_interchange_and_wait` |
87
- | Assistant | `vg.assistant` | `start_assistant_chat_and_wait`, `send_assistant_message_and_wait` |
88
- | Entities | `vg.entities` | `create_entity`, `list_entities`, `add_entity_reference` |
89
- | Text | `vg.text` | `generate_text` |
90
- | Catalog | `vg.resources` | `list_tts_voices`, `list_languages` |
91
- | Webhooks | `vg.webhooks` + helper | `create_webhook_endpoint`, `verify_webhook_signature` |
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` |
92
93
 
93
94
  Prefer `*_and_wait` (or the matching `poll_*` / `async_poll_*` helper) for anything asynchronous. Thin REST methods match OpenAPI `operationId`s (snake_case).
94
95
 
@@ -98,6 +99,35 @@ Prefer `*_and_wait` (or the matching `poll_*` / `async_poll_*` helper) for anyth
98
99
  - **Requests:** pass snake_case kwargs (and nested dict keys). The client serializes body/query keys to camelCase for the wire.
99
100
  - **Responses:** JSON objects are converted recursively to snake_case keys (`tool_execution_id`, `workflow_run_id`, `has_more`).
100
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
+
101
131
  ## Workflows
102
132
 
103
133
  Script to video (above) is the usual path. Prompt to video clip builds a single clip from a prompt:
@@ -115,7 +145,7 @@ run = vg.workflows.prompt_to_video_clip_and_wait(
115
145
  print(run.download_url)
116
146
  ```
117
147
 
118
- 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`).
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`).
119
149
 
120
150
  ## Tools
121
151
 
@@ -161,7 +191,7 @@ vg.download_file(uploaded["file_id"], output_path="output.mp4")
161
191
 
162
192
  ## Projects
163
193
 
164
- Export a finished workflow project, or apply remix actions later:
194
+ Export a finished workflow project, or apply video edits later:
165
195
 
166
196
  ```python
167
197
  import os
@@ -174,14 +204,15 @@ project_id = "vg_proj_..."
174
204
  exported = vg.projects.export_and_wait(project_id=project_id, quality="HIGH")
175
205
  print(exported["status"], exported.get("export_file_id"))
176
206
 
177
- remix = vg.projects.remix_and_wait(
207
+ edits = vg.projects.start_video_edits_and_wait(
178
208
  project_id=project_id,
179
- remix_actions=[
209
+ editable_video_id="editable-video-id",
210
+ video_edits=[
180
211
  {"type": "ENABLE_CAPTIONS"},
181
212
  {"type": "ADD_TRANSITIONS"},
182
213
  ],
183
214
  )
184
- print(remix)
215
+ print(edits)
185
216
  ```
186
217
 
187
218
  ## Assistant
@@ -260,20 +291,20 @@ Register endpoints with `vg.webhooks.create_webhook_endpoint`. Signatures follow
260
291
 
261
292
  Exported as module functions and bound on the client:
262
293
 
263
- | Helper | Purpose |
264
- | --- | --- |
265
- | `poll_assistant_message` / `async_poll_assistant_message` | Poll an assistant message to a terminal status |
266
- | `poll_executed_tool` / `async_poll_executed_tool` | Poll a tool execution to a terminal status or `awaiting_approval` |
267
- | `poll_workflow_run` / `async_poll_workflow_run` | Poll a workflow run to a terminal status or `awaiting_approval` |
268
- | `poll_project_export` / `async_poll_project_export` | Poll a project export |
269
- | `poll_timeline_interchange` / `async_poll_timeline_interchange` | Poll a timeline interchange job |
270
- | `poll_remix_actions` / `async_poll_remix_actions` | Poll remix actions until all are terminal |
271
- | `poll_public_preview` / `async_poll_public_preview` | Poll until a public preview URL is ready |
272
- | `upload_file` / `async_upload_file` | Presign, PUT bytes, poll until the file is ready |
273
- | `get_hydrated_file` / `async_get_hydrated_file` | Hydrate signed source URLs |
274
- | `download_file` / `async_download_file` | Hydrate then download bytes (optional path) |
275
- | `create_public_preview` / `async_create_public_preview` | Enable + poll public preview |
276
- | `verify_webhook_signature` | Verify Standard Webhooks and return the event dict |
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 |
277
308
 
278
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.
279
310
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "videogen"
7
- version = "2.5.3"
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"
@@ -12,6 +12,7 @@ from .async_poll_executed_tool import async_poll_executed_tool
12
12
  from .async_poll_file_url_import import async_poll_file_url_import
13
13
  from .async_poll_project_export import async_poll_project_export
14
14
  from .async_poll_public_preview import async_poll_public_preview
15
+ from .async_poll_video_edits import async_poll_video_edits
15
16
  from .async_poll_remix_actions import async_poll_remix_actions
16
17
  from .async_poll_timeline_interchange import async_poll_timeline_interchange
17
18
  from .async_poll_workflow_run import async_poll_workflow_run
@@ -26,6 +27,7 @@ from .poll_executed_tool import poll_executed_tool
26
27
  from .poll_file_url_import import poll_file_url_import
27
28
  from .poll_project_export import poll_project_export
28
29
  from .poll_public_preview import poll_public_preview
30
+ from .poll_video_edits import poll_video_edits
29
31
  from .poll_remix_actions import poll_remix_actions
30
32
  from .poll_timeline_interchange import poll_timeline_interchange
31
33
  from .poll_workflow_run import poll_workflow_run
@@ -45,6 +47,7 @@ __all__ = [
45
47
  "async_poll_file_url_import",
46
48
  "async_poll_project_export",
47
49
  "async_poll_public_preview",
50
+ "async_poll_video_edits",
48
51
  "async_poll_remix_actions",
49
52
  "async_poll_timeline_interchange",
50
53
  "async_poll_workflow_run",
@@ -57,6 +60,7 @@ __all__ = [
57
60
  "poll_file_url_import",
58
61
  "poll_project_export",
59
62
  "poll_public_preview",
63
+ "poll_video_edits",
60
64
  "poll_remix_actions",
61
65
  "poll_timeline_interchange",
62
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
@@ -0,0 +1,49 @@
1
+ from __future__ import annotations
2
+
3
+ import time
4
+ from typing import Any, Optional, Sequence
5
+
6
+ from .poll_helpers import (
7
+ async_poll_sleep,
8
+ ensure_within_timeout,
9
+ poll_raise_if_cancelled,
10
+ )
11
+ from .poll_video_edits import _get_video_edit_poll_result
12
+
13
+
14
+ async def async_poll_video_edits(
15
+ client: Any,
16
+ project_id: str,
17
+ *,
18
+ editable_video_id: Optional[str] = None,
19
+ video_edit_ids: Optional[Sequence[str]] = None,
20
+ poll_interval_ms: int = 1500,
21
+ timeout_ms: Optional[int] = 3_600_000,
22
+ throw_on_failure: bool = True,
23
+ cancel_event: Any = None,
24
+ ) -> dict:
25
+ """Poll video edits, optionally limited to the exact ids returned by a start."""
26
+ started_at = time.monotonic()
27
+ while True:
28
+ poll_raise_if_cancelled(cancel_event)
29
+ ensure_within_timeout(started_at=started_at, timeout_ms=timeout_ms)
30
+ edits = []
31
+ cursor = None
32
+ while True:
33
+ poll_raise_if_cancelled(cancel_event)
34
+ ensure_within_timeout(started_at=started_at, timeout_ms=timeout_ms)
35
+ listing = await client.projects.list_video_edits(
36
+ project_id=project_id,
37
+ editable_video_id=editable_video_id,
38
+ limit=200,
39
+ cursor=cursor,
40
+ cancel_event=cancel_event,
41
+ )
42
+ edits.extend(listing.get("video_edits") or [])
43
+ cursor = listing.get("next_cursor")
44
+ if not listing.get("has_more") or cursor is None:
45
+ break
46
+ result = _get_video_edit_poll_result(edits, video_edit_ids, throw_on_failure)
47
+ if result is not None:
48
+ return result
49
+ await async_poll_sleep(poll_interval_ms, cancel_event)
@@ -13,6 +13,7 @@ from .async_poll_executed_tool import async_poll_executed_tool
13
13
  from .async_poll_file_url_import import async_poll_file_url_import
14
14
  from .async_poll_project_export import async_poll_project_export
15
15
  from .async_poll_public_preview import async_poll_public_preview
16
+ from .async_poll_video_edits import async_poll_video_edits
16
17
  from .async_poll_remix_actions import async_poll_remix_actions
17
18
  from .async_poll_timeline_interchange import async_poll_timeline_interchange
18
19
  from .async_poll_workflow_run import async_poll_workflow_run
@@ -25,11 +26,14 @@ from .poll_executed_tool import poll_executed_tool
25
26
  from .poll_file_url_import import poll_file_url_import
26
27
  from .poll_project_export import poll_project_export
27
28
  from .poll_public_preview import poll_public_preview
29
+ from .poll_video_edits import poll_video_edits
28
30
  from .poll_remix_actions import poll_remix_actions
29
31
  from .poll_timeline_interchange import poll_timeline_interchange
30
32
  from .poll_workflow_run import poll_workflow_run
31
33
  from .resources.account import AccountResource, AsyncAccountResource
32
34
  from .resources.assistant import AssistantResource, AsyncAssistantResource
35
+ from .resources.models import AsyncModelsResource, ModelsResource
36
+ from .resources.billing import AsyncBillingResource, BillingResource
33
37
  from .resources.entities import AsyncEntitiesResource, EntitiesResource
34
38
  from .resources.files import AsyncFilesResource, FilesResource
35
39
  from .resources.projects import AsyncProjectsResource, ProjectsResource
@@ -62,6 +66,8 @@ class VideoGen:
62
66
  client_id=client_id,
63
67
  )
64
68
  self.account = AccountResource(self)
69
+ self.billing = BillingResource(self)
70
+ self.models = ModelsResource(self)
65
71
  self.workflows = WorkflowsResource(self)
66
72
  self.projects = ProjectsResource(self)
67
73
  self.tools = ToolsResource(self)
@@ -117,6 +123,9 @@ class VideoGen:
117
123
  def poll_file_url_import(self, file_import_id: str, **kwargs: Any) -> dict:
118
124
  return poll_file_url_import(self, file_import_id, **kwargs)
119
125
 
126
+ def poll_video_edits(self, project_id: str, **kwargs: Any) -> dict:
127
+ return poll_video_edits(self, project_id, **kwargs)
128
+
120
129
  def poll_remix_actions(self, project_id: str, **kwargs: Any) -> dict:
121
130
  return poll_remix_actions(self, project_id, **kwargs)
122
131
 
@@ -159,6 +168,8 @@ class AsyncVideoGen:
159
168
  client_id=client_id,
160
169
  )
161
170
  self.account = AsyncAccountResource(self)
171
+ self.billing = AsyncBillingResource(self)
172
+ self.models = AsyncModelsResource(self)
162
173
  self.workflows = AsyncWorkflowsResource(self)
163
174
  self.projects = AsyncProjectsResource(self)
164
175
  self.tools = AsyncToolsResource(self)
@@ -218,6 +229,9 @@ class AsyncVideoGen:
218
229
  async def poll_file_url_import(self, file_import_id: str, **kwargs: Any) -> dict:
219
230
  return await async_poll_file_url_import(self, file_import_id, **kwargs)
220
231
 
232
+ async def poll_video_edits(self, project_id: str, **kwargs: Any) -> dict:
233
+ return await async_poll_video_edits(self, project_id, **kwargs)
234
+
221
235
  async def poll_remix_actions(self, project_id: str, **kwargs: Any) -> dict:
222
236
  return await async_poll_remix_actions(self, project_id, **kwargs)
223
237
 
@@ -13,10 +13,13 @@ class VideoGenError(Exception):
13
13
  status: int,
14
14
  body: Any = None,
15
15
  request_id: Optional[str] = None,
16
+ retry_after: Optional[str] = None,
16
17
  ) -> None:
17
18
  super().__init__(message)
18
19
  self.status = status
19
20
  self.body = body
21
+ self.retry_after = retry_after
22
+ self.retryAfter = retry_after
20
23
  self.request_id = request_id
21
24
  # camelCase alias for cross-language parity with the TypeScript SDK
22
25
  self.requestId = request_id
@@ -0,0 +1,72 @@
1
+ from __future__ import annotations
2
+
3
+ import time
4
+ from typing import Any, Optional, Sequence
5
+
6
+ from .errors import VideoGenError
7
+ from .poll_helpers import (
8
+ TERMINAL_STATUSES,
9
+ poll_sleep,
10
+ ensure_within_timeout,
11
+ poll_raise_if_cancelled,
12
+ )
13
+
14
+
15
+ def poll_video_edits(
16
+ client: Any,
17
+ project_id: str,
18
+ *,
19
+ editable_video_id: Optional[str] = None,
20
+ video_edit_ids: Optional[Sequence[str]] = None,
21
+ poll_interval_ms: int = 1500,
22
+ timeout_ms: Optional[int] = 3_600_000,
23
+ throw_on_failure: bool = True,
24
+ cancel_event: Any = None,
25
+ ) -> dict:
26
+ """Poll video edits, optionally limited to the exact ids returned by a start."""
27
+ started_at = time.monotonic()
28
+ while True:
29
+ poll_raise_if_cancelled(cancel_event)
30
+ ensure_within_timeout(started_at=started_at, timeout_ms=timeout_ms)
31
+ edits = []
32
+ cursor = None
33
+ while True:
34
+ poll_raise_if_cancelled(cancel_event)
35
+ ensure_within_timeout(started_at=started_at, timeout_ms=timeout_ms)
36
+ listing = client.projects.list_video_edits(
37
+ project_id=project_id,
38
+ editable_video_id=editable_video_id,
39
+ limit=200,
40
+ cursor=cursor,
41
+ cancel_event=cancel_event,
42
+ )
43
+ edits.extend(listing.get("video_edits") or [])
44
+ cursor = listing.get("next_cursor")
45
+ if not listing.get("has_more") or cursor is None:
46
+ break
47
+ result = _get_video_edit_poll_result(edits, video_edit_ids, throw_on_failure)
48
+ if result is not None:
49
+ return result
50
+ poll_sleep(poll_interval_ms, cancel_event)
51
+
52
+
53
+ def _get_video_edit_poll_result(
54
+ edits: list,
55
+ video_edit_ids: Optional[Sequence[str]],
56
+ throw_on_failure: bool,
57
+ ) -> Optional[dict]:
58
+ if video_edit_ids is not None:
59
+ requested_ids = set(video_edit_ids)
60
+ edits = [edit for edit in edits if edit.get("video_edit_id") in requested_ids]
61
+ if {edit.get("video_edit_id") for edit in edits} != requested_ids:
62
+ return None
63
+ elif not edits:
64
+ return None
65
+ if not all(edit.get("status") in TERMINAL_STATUSES for edit in edits):
66
+ return None
67
+ result = {"video_edits": edits, "has_more": False, "next_cursor": None}
68
+ if throw_on_failure and any(edit.get("status") in ("failed", "cancelled") for edit in edits):
69
+ raise VideoGenError(
70
+ "One or more video edits failed or were cancelled.", status=0, body=result,
71
+ )
72
+ return result