runapi-grok-imagine 0.2.8 → 0.2.10

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1e3242748745f800a98bf97daa49bf3a9257e8cd789fd7ad641bc43bd56e864
4
- data.tar.gz: 639d984e396f8ca06f774e7e52750b0ec7d23db588ec7670495673ffce3adb14
3
+ metadata.gz: af3b5de5478268a1ab943a736e88c6dfeda6863f5f9ec55d597a879cd5f3c5e9
4
+ data.tar.gz: def751a3227b6e4bd803fd9dd5a0ceab53480f23ced9c47e5ab53ad1f7cebdc3
5
5
  SHA512:
6
- metadata.gz: cc1472f349ac8211430c488460c74d5b1254069e39006247cdedc94975d86cd48d4fa6098883f876d5b9593b75c1dfbd665fd02bd2e2a237b5bd06722cc032e3
7
- data.tar.gz: 0dc17d476484b3957c40ec0be32f9ad4c667ee07dd7103630bea6bb5ab8aa592624addf3ba7fbc27ff77834f1dafafd0f526d5fefe53b7786892a7d07b586564
6
+ metadata.gz: 9603cd865825dd1a1c7040d501e60b99c94268a6b7d8ee19e87c3bd168d4833e7be93c3e3480c778a90c842434ec98a45cd78ad69f6bf9f39ea38d952b60e057
7
+ data.tar.gz: 4f1be7f7daa025d98a22fd9c744024bb5348e63ee34bdc2dc8b40fb93672e4f6e96b89d8f4d57126272253069886956a4adf23680e1645db9e4f78f183adcbd1
data/README.md CHANGED
@@ -28,7 +28,7 @@ RunAPI-generated file URLs are temporary. Download and store generated images, v
28
28
 
29
29
  ## Language notes
30
30
 
31
- Use Ruby keyword arguments and the `RunApi::GrokImagine` error classes when building media jobs, Rails workers, or scripts. The available resources are `text_to_video`, `image_to_video`, `text_to_image`, `edit_image`, `extensions`, and `upscales`; use `grok-imagine-video-1.5-preview` with either video resource for the preview model. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
31
+ Use Ruby keyword arguments and the `RunApi::GrokImagine` error classes when building media jobs, Rails workers, or scripts. The available resources are `text_to_video`, `image_to_video`, `text_to_image`, `edit_image`, `extensions`, and `upscales`; use `grok-imagine-video-1.5-fast` or `grok-imagine-video-1.5-preview` with either video resource. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
32
32
 
33
33
  ## Links
34
34
 
@@ -36,6 +36,7 @@ Use Ruby keyword arguments and the `RunApi::GrokImagine` error classes when buil
36
36
  - SDK docs: https://runapi.ai/docs#sdk-grok-imagine
37
37
  - Product docs: https://runapi.ai/docs#grok-imagine
38
38
  - Video 1.5 Preview pricing and rate limits: https://runapi.ai/models/grok-imagine/video-1.5-preview
39
+ - Video 1.5 Fast pricing and rate limits: https://runapi.ai/models/grok-imagine/video-1.5-fast
39
40
  - Text-to-video pricing and rate limits: https://runapi.ai/models/grok-imagine/text-to-video
40
41
  - Image-to-video pricing and rate limits: https://runapi.ai/models/grok-imagine/image-to-video
41
42
  - Provider comparison: https://runapi.ai/providers/xai
@@ -28,7 +28,7 @@ module RunApi
28
28
  }
29
29
  },
30
30
  "image-to-video" => {
31
- "models" => ["grok-imagine-image-to-video", "grok-imagine-video-1.5-preview"],
31
+ "models" => ["grok-imagine-image-to-video", "grok-imagine-video-1.5-fast", "grok-imagine-video-1.5-preview"],
32
32
  "fields_by_model" => {
33
33
  "grok-imagine-image-to-video" => {
34
34
  "aspect_ratio" => {
@@ -47,6 +47,25 @@ module RunApi
47
47
  "enum" => ["480p", "720p"]
48
48
  }
49
49
  },
50
+ "grok-imagine-video-1.5-fast" => {
51
+ "aspect_ratio" => {
52
+ "enum" => ["1:1", "16:9", "9:16", "3:2", "2:3"]
53
+ },
54
+ "duration_seconds" => {
55
+ "min" => 1,
56
+ "max" => 30,
57
+ "type" => "integer"
58
+ },
59
+ "index" => {
60
+ "type" => "integer"
61
+ },
62
+ "output_resolution" => {
63
+ "enum" => ["480p", "720p"]
64
+ },
65
+ "source_image_url" => {
66
+ "required" => true
67
+ }
68
+ },
50
69
  "grok-imagine-video-1.5-preview" => {
51
70
  "aspect_ratio" => {
52
71
  "enum" => ["1:1", "16:9", "9:16", "3:2", "2:3", "auto"]
@@ -67,16 +86,26 @@ module RunApi
67
86
  "max" => 4096,
68
87
  "length" => true
69
88
  },
70
- "source_image_urls" => {
89
+ "source_image_url" => {
71
90
  "required" => true
72
91
  }
73
92
  }
74
93
  },
75
94
  "rules" => [{
76
95
  "when" => {
77
- "model" => "grok-imagine-video-1.5-preview"
96
+ "model" => "grok-imagine-image-to-video"
97
+ },
98
+ "forbidden" => ["reference_image_urls"]
99
+ }, {
100
+ "when" => {
101
+ "model" => "grok-imagine-video-1.5-fast"
78
102
  },
79
103
  "forbidden" => ["source_task_id", "index", "motion_style", "enable_safety_checker"]
104
+ }, {
105
+ "when" => {
106
+ "model" => "grok-imagine-video-1.5-preview"
107
+ },
108
+ "forbidden" => ["source_task_id", "index", "reference_image_urls", "motion_style", "enable_safety_checker"]
80
109
  }]
81
110
  },
82
111
  "text-to-image" => {
@@ -90,7 +119,7 @@ module RunApi
90
119
  }
91
120
  },
92
121
  "text-to-video" => {
93
- "models" => ["grok-imagine-text-to-video", "grok-imagine-video-1.5-preview"],
122
+ "models" => ["grok-imagine-text-to-video", "grok-imagine-video-1.5-fast", "grok-imagine-video-1.5-preview"],
94
123
  "fields_by_model" => {
95
124
  "grok-imagine-text-to-video" => {
96
125
  "aspect_ratio" => {
@@ -106,6 +135,22 @@ module RunApi
106
135
  "enum" => ["480p", "720p"]
107
136
  }
108
137
  },
138
+ "grok-imagine-video-1.5-fast" => {
139
+ "aspect_ratio" => {
140
+ "enum" => ["1:1", "16:9", "9:16", "3:2", "2:3"]
141
+ },
142
+ "duration_seconds" => {
143
+ "min" => 1,
144
+ "max" => 30,
145
+ "type" => "integer"
146
+ },
147
+ "output_resolution" => {
148
+ "enum" => ["480p", "720p"]
149
+ },
150
+ "prompt" => {
151
+ "required" => true
152
+ }
153
+ },
109
154
  "grok-imagine-video-1.5-preview" => {
110
155
  "aspect_ratio" => {
111
156
  "enum" => ["1:1", "16:9", "9:16", "3:2", "2:3", "auto"]
@@ -128,9 +173,19 @@ module RunApi
128
173
  },
129
174
  "rules" => [{
130
175
  "when" => {
131
- "model" => "grok-imagine-video-1.5-preview"
176
+ "model" => "grok-imagine-text-to-video"
177
+ },
178
+ "forbidden" => ["reference_image_urls"]
179
+ }, {
180
+ "when" => {
181
+ "model" => "grok-imagine-video-1.5-fast"
132
182
  },
133
183
  "forbidden" => ["motion_style", "enable_safety_checker"]
184
+ }, {
185
+ "when" => {
186
+ "model" => "grok-imagine-video-1.5-preview"
187
+ },
188
+ "forbidden" => ["reference_image_urls", "motion_style", "enable_safety_checker"]
134
189
  }]
135
190
  },
136
191
  "upscale-image" => {
@@ -4,7 +4,7 @@ module RunApi
4
4
  module GrokImagine
5
5
  module Resources
6
6
  # Grok-Imagine image-to-video generation resource.
7
- # Accepts either external source_image_urls or a prior text-to-image source_task_id (+ index).
7
+ # Accepts either an external source_image_url or a prior text-to-image source_task_id (+ index).
8
8
  class ImageToVideo
9
9
  include RunApi::Core::ResourceHelpers
10
10
 
@@ -37,17 +37,14 @@ module RunApi
37
37
  def validate_params!(params)
38
38
  validate_contract!(CONTRACT["image-to-video"], params)
39
39
 
40
- source_image_urls = param(params, :source_image_urls)
40
+ source_image_url = param(params, :source_image_url)
41
41
  source_task_id = param(params, :source_task_id)
42
42
 
43
- if source_image_urls && !source_image_urls.empty? && source_task_id
44
- raise Core::ValidationError, "Provide either source_image_urls or source_task_id, not both"
43
+ if source_image_url && source_task_id
44
+ raise Core::ValidationError, "Provide either source_image_url or source_task_id, not both"
45
45
  end
46
- if (!source_image_urls || source_image_urls.empty?) && !source_task_id
47
- raise Core::ValidationError, "One of source_image_urls or source_task_id is required"
48
- end
49
- if source_image_urls && source_image_urls.size > 1
50
- raise Core::ValidationError, "source_image_urls supports at most 1 entry"
46
+ unless source_image_url || source_task_id
47
+ raise Core::ValidationError, "One of source_image_url or source_task_id is required"
51
48
  end
52
49
 
53
50
  if source_task_id && (index = param(params, :index))
@@ -57,7 +54,7 @@ module RunApi
57
54
  end
58
55
  end
59
56
 
60
- if param(params, :motion_style).to_s == "spicy" && source_image_urls && !source_image_urls.empty?
57
+ if param(params, :motion_style).to_s == "spicy" && source_image_url
61
58
  raise Core::ValidationError, "spicy motion_style requires a source_task_id source image."
62
59
  end
63
60
  end
@@ -40,7 +40,14 @@ module RunApi
40
40
  duration_seconds = param(params, :duration_seconds)
41
41
  if duration_seconds
42
42
  int = duration_seconds.to_i
43
- range = (param(params, :model) == Types::PREVIEW_MODEL) ? Types::PREVIEW_DURATION_RANGE : Types::DURATION_RANGE
43
+ range = case param(params, :model)
44
+ when Types::FAST_MODEL
45
+ Types::FAST_DURATION_RANGE
46
+ when Types::PREVIEW_MODEL
47
+ Types::PREVIEW_DURATION_RANGE
48
+ else
49
+ Types::DURATION_RANGE
50
+ end
44
51
  unless range.cover?(int)
45
52
  raise Core::ValidationError, "duration_seconds must be an integer between #{range.min} and #{range.max}"
46
53
  end
@@ -4,6 +4,8 @@ module RunApi
4
4
  module GrokImagine
5
5
  module Types
6
6
  DURATION_RANGE = (6..30)
7
+ FAST_MODEL = "grok-imagine-video-1.5-fast"
8
+ FAST_DURATION_RANGE = (1..30)
7
9
  PREVIEW_MODEL = "grok-imagine-video-1.5-preview"
8
10
  PREVIEW_DURATION_RANGE = (1..15)
9
11
  EXTENSION_DURATION_SECONDS = [6, 10].freeze
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runapi-grok-imagine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - RunAPI
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.2.11
18
+ version: 0.2.13
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: 0.2.11
25
+ version: 0.2.13
26
26
  description: The Grok Imagine Ruby SDK is the language-specific package for Grok Imagine
27
27
  on RunAPI. Use this package for image and video generation, image editing, and creative
28
28
  production workflows when your application needs request bodies, task status lookup,