Repository navigation
v1.0.56
Changes
Prompture has been quietly competent at text and image generation for a while — this PR drags it the rest of the way into the multi-modal world. It adds a brand-new video generation modality (with Grok Imagine and seven Runway video models behind it) and rounds out the Runway surface across image, TTS, sound effects, and voice transforms, all under a single API key.
Highlights
- Generate videos from text or image inputs via
get_video_gen_driver_for_model("grok/grok-imagine-video")orget_video_gen_driver_for_model("runway/gen4.5"), with polling, cost reporting, and the sameprovider/modelrouting as the rest of the library. - One Runway key (
RUNWAY_API_KEYorRUNWAYML_API_SECRET) now unlocks image generation (gen4_image,gen4_image_turbo,gpt_image_2,gemini_image3_pro,gemini_2.5_flash), video (gen4.5,gen4_turbo,gen3a_turbo,gen4_aleph,veo3,veo3.1,veo3.1_fast), TTS (eleven_multilingual_v2with 49 preset voices), and sound effects (eleven_text_to_sound_v2). - New
RunwayAudioTransformDrivercovers voice dubbing across 29 languages, voice isolation, and speech-to-speech voice conversion — operations that don't fit STT/TTS shape and so live as a standalone helper. - A capability registry (
get_runway_model_info,get_runway_models_by_op,get_runway_models_by_modality) lets callers ask "which Runway models do text_to_video?" as data, without instantiating drivers. get_available_video_gen_models()joins the existing image / audio / embedding discovery helpers, and auto-detects video-capable models from configured provider keys plus the models.dev fallback.- Three runnable examples in
examples/for video, image, and audio Runway flows, plus a Grok video example.
Technical changes
- New video generation modality:
prompture/drivers/video_gen_base.pyaddsVideoGenDriverwith the response contract (videos,meta.video_count,duration_seconds,aspect_ratio,resolution,cost,model_name,raw_response), capability flags (supports_image_input,supports_reference_images,supports_video_input,supports_audio,supports_polling,supported_aspect_ratios,supported_resolutions,max_seconds), andgenerate_video_with_hooksforon_request/on_response/on_errorcallbacks.async_video_gen_base.pymirrors it for async.prompture/drivers/registry.pygains_video_gen_sync/_video_gen_asyncDriverRegistryinstances plus the full set of public functions (register_video_gen_driver,unregister_video_gen_driver,list_registered_video_gen_drivers,is_video_gen_driver_registered,get_video_gen_driver_factory,load_video_gen_entry_point_drivers, async siblings, and_get_video_gen_registry/_get_async_video_gen_registry). Both registries are reset by_reset_registries.prompture/drivers/video_gen_registry.pyexposes theget_video_gen_driver_for_model/get_async_video_gen_driver_for_modelfactories that parse"provider/model"strings.
VideoCostMixinadded toprompture/infra/cost_mixin.py._calculate_video_costresolves cost in this order: resolution-specificper_second_by_resolution[resolution] × duration_seconds, then genericper_second × duration_seconds, thenper_video, thendefault.prompture/media/video.pyintroducesVideoContent(frozen dataclass withdata,media_type,source_type,url,duration_seconds,width,height), theVideoInputtype alias, and constructorsvideo_from_bytes,video_from_base64,video_from_file,video_from_url, andmake_video. MIME detection covers MP4 / MOV / WebM / MKV / AVI / MPEG via extension lookup, magic-byte sniffing (EBML for WebM,ftypbox for MP4/MOV), and a_DATA_URI_REmatcher fordata:video/...URIs.- New Grok video generation driver
prompture/drivers/grok_video_gen_driver.py(sync) andasync_grok_video_gen_driver.py(async) targeting the xAIPOST /videos/generations+GET /videos/{id}endpoints. Validates duration (1-15 s, max 10 s when reference images are used), aspect ratio (1:1,16:9,9:16,4:3,3:4,3:2,2:3), resolution (480p/720p), and rejectsimage+reference_imagescombinations. Reference images limited to seven.VIDEO_PRICINGusesper_second_by_resolution:$0.05/sat 480p,$0.07/sat 720p. AcceptsGROK_API_KEYorXAI_API_KEY, polls the task with configurablepoll_interval/timeout, returns request_id-only response whenpoll=False. SupportsImageInput/dict/ data-URI inputs throughmake_image. - New Runway image driver
runway_img_gen_driver.py(+ async) hitsPOST /v1/text_to_imagethen pollsGET /v1/tasks/{id}untilSUCCEEDED/FAILED/CANCELLED. Enforces the 16 documentedtext_to_imageratios, requiresreference_imagesforgen4_image_turbo, rejectsqualityon models other thangpt_image_2, normalizes reference image dicts to{uri, tag}, and parses Runway's structurederror/issuesbody into a single error string via_format_error. Pricing covers all five models with size/quality buckets where Runway differentiates. Default ratios per model live in_DEFAULT_RATIOS. HeaderX-Runway-Version: 2024-11-06. - New Runway video driver
runway_video_gen_driver.py(+ async) handles all three video endpoints (/v1/text_to_video,/v1/image_to_video,/v1/video_to_video) in one class._detect_modepicks the endpoint from an explicitmodeoption or auto-detects fromvideo/imagepresence in options. Per-mode model allow-lists (_KNOWN_MODELS_BY_MODE) and per-endpoint ratio sets (_T2V_RATIOS,_I2V_RATIOS)._normalize_prompt_imageaccepts strings, dicts, or lists of keyframe dicts and emits the rightpromptImageshape.VIDEO_PRICINGis per-second per model ($0.05–$0.40/s). - New Runway TTS driver
runway_tts_driver.py(+ async) routes by model: anyeleven_text_to_sound_v2request hits/v1/sound_effect, anything else hits/v1/text_to_speech. Sound effects acceptduration(0.5–30 s) andloop. TTS requires a preset voice — either a string preset name resolved to{type: runway-preset, presetId: ...}or a full voice dict. The 49 Runway preset voice names are exposed asavailable_voices.AudioCostMixinprovides per-character TTS pricing ($0.000030/char) and per-second sound-effect pricing ($0.04/s). - New
runway_audio_transform_driver.pyaddsRunwayAudioTransformDriverfor the three operations that take audio and return audio:dub(audio, target_lang, ...)(29 ISO-639-1 codes validated againstDUBBING_LANGUAGES),isolate(audio, ...), andconvert_voice(media, voice_preset_id, media_kind="audio"|"video", ...). All three submit a task, poll until terminal, download the resulting audio via the_fetch_audiohelper, and return{audio, media_type, meta}. Lives outside the modality registry by design — STT and TTS contracts don't apply. runway_capabilities.pydeclaresRUNWAY_MODEL_INFO: dict[str, RunwayModelInfo]covering 16 Runway models with modality, operations, endpoints, and cost notes. Exposesget_runway_model_info(model_id_or_provider_path),get_runway_models_by_op(operation), andget_runway_models_by_modality(modality), plusALL_OPERATIONS/ALL_MODALITIESsorted lists.provider_descriptors.pyaddsvideo_gen_sync/video_gen_asyncfields toProviderDescriptor, a full Runway descriptor wiring image + video + TTS modalities, a new_runway_kwlookup (runway_api_key,runway_endpoint), and arunwaymlalias forrunwaycovering{img_gen, video_gen, tts}. Thexaialias forgroknow also coversvideo_gen. The descriptor-drivenregister_all_builtin_drivers()learns the two new modalities viaregister_video_gen_driver/register_async_video_gen_driver. Grok descriptor addsvideo_gen_sync/video_gen_asyncpointing at the new drivers withgrok_video_modelas the default key.prompture/infra/settings.pyaddsxai_api_key,grok_video_model(defaultgrok-imagine-video),runway_api_key, andrunway_endpoint.provider_env.pyaddsxai_api_keytoProviderEnvironmentfor per-consumer isolation.prompture/infra/discovery.pyaddsget_available_video_gen_models()(Grok + Runway via staticKNOWN_MODELS, plus a models.dev fallback that scanscaps.modalities_outputfor"video"), and extendsget_available_image_gen_modelsandget_available_audio_modelsto include Runway when the key is present.prompture/drivers/__init__.pyexports all new drivers, registry functions, the Runway capability helpers, andVideoGenDriver/AsyncVideoGenDriverbase classes.__all__updated.prompture/infra/__init__.pyre-exportsVideoCostMixinandget_available_video_gen_models.- New examples:
examples/grok_video_generation_example.py,examples/runway_image_generation_example.py,examples/runway_video_generation_example.py,examples/runway_audio_example.py. .env.copydocumentsXAI_API_KEY,GROK_VIDEO_MODEL, and the Runway block..gitignoreadds entries for example output artifacts.README.mdandCLAUDE.mddocument the new video modality, the Runway surface, the capability registry, and the discovery helpers. Provider count bumped from 17+ to 18+.