@remotion-studio/sdk 0.1.0 → 0.1.1

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 (2) hide show
  1. package/README.md +213 -208
  2. package/package.json +20 -4
package/README.md CHANGED
@@ -1,56 +1,13 @@
1
- # Remotion Studio
1
+ # @remotion-studio/sdk
2
2
 
3
- Generate, edit, play, and render AI-created Remotion compositions from your own apps.
3
+ Official SDK for the hosted Remotion Studio API.
4
4
 
5
- `@remotion-studio/sdk` is the official package for [Remotion Studio](https://remotionstudio.io). It gives you:
5
+ This package includes:
6
6
 
7
- - `@remotion-studio/sdk` to call the Remotion Studio API
8
- - `@remotion-studio/sdk/runtime` to render returned artifacts inside a Remotion project
7
+ - `@remotion-studio/sdk` for calling the API
8
+ - `@remotion-studio/sdk/runtime` for rendering returned artifacts inside Remotion or `@remotion/player`
9
9
 
10
- If you want a visual workflow, use the Remotion Studio UI. If you want to automate generation, build editors, run async jobs, or embed generated scenes in your own product, use the SDK.
11
-
12
- With this package you can:
13
-
14
- - generate new Remotion compositions from prompts
15
- - edit compositions through follow-up instructions
16
- - play returned artifacts directly inside a Remotion app
17
- - queue long-running async generation or edit jobs
18
- - start Remotion Lambda renders and track render progress
19
- - embed the returned artifact directly inside your own Remotion app
20
-
21
- ## Why Use It
22
-
23
- - Generate motion graphics from prompts
24
- - Edit existing compositions iteratively
25
- - Play returned artifacts immediately in Remotion
26
- - Stream generation output
27
- - Queue long-running jobs and use polling or webhooks
28
- - Start cloud renders and poll for the final video output
29
- - Render the returned artifact directly inside Remotion
30
-
31
- ## Use It Two Ways
32
-
33
- ### 1. Use the UI
34
-
35
- Use [Remotion Studio](https://remotionstudio.io) when you want a visual workflow:
36
-
37
- - create and refine compositions in the browser
38
- - manage prompts, edits, and threads
39
- - create API tokens for external apps
40
-
41
- ### 2. Use the API and SDK
42
-
43
- Use `@remotion-studio/sdk` when you want to:
44
-
45
- - generate compositions from your own app
46
- - build internal tools or automations
47
- - trigger async jobs from servers or background workers
48
- - start Remotion Lambda renders programmatically
49
- - embed generated artifacts in a Remotion pipeline
50
-
51
- ## Quick Start
52
-
53
- Install:
10
+ ## Install
54
11
 
55
12
  ```bash
56
13
  npm install @remotion-studio/sdk
@@ -64,137 +21,89 @@ pnpm add @remotion-studio/sdk
64
21
  bun add @remotion-studio/sdk
65
22
  ```
66
23
 
67
- Create a client:
24
+ ## Authentication
25
+
26
+ Create a personal API token in the Remotion Studio web app, then use it as a bearer token.
68
27
 
69
28
  ```ts
70
29
  import { createRemotionStudioClient } from "@remotion-studio/sdk";
71
30
 
72
31
  const client = createRemotionStudioClient({
73
- baseUrl: "https://your-remotionstudio-domain.com",
32
+ baseUrl: "https://remotionstudio.io",
74
33
  headers: {
75
34
  Authorization: `Bearer ${process.env.REMOTIONSTUDIO_API_TOKEN}`,
76
35
  },
77
36
  });
78
37
  ```
79
38
 
80
- Generate a composition:
81
-
82
- ```ts
83
- const generated = await client.generate({
84
- prompt: "A cinematic product hero reveal with dramatic lighting",
85
- reasoningEffort: "none",
86
- });
87
- ```
39
+ The plaintext token is shown only once when it is created.
88
40
 
89
- Edit it:
41
+ ## Client Options
90
42
 
91
- ```ts
92
- const edited = await client.edit({
93
- prompt: "Make it faster, cleaner, and more typography-driven",
94
- currentCode: generated.code,
95
- threadId: generated.thread?.id,
96
- });
97
- ```
43
+ `createRemotionStudioClient()` accepts:
98
44
 
99
- Use the artifact in Remotion:
45
+ - `baseUrl?: string`
46
+ - `headers?: HeadersInit`
47
+ - `fetch?: typeof fetch`
100
48
 
101
- ```tsx
102
- import { MotionGraphicsSlot } from "@remotion-studio/sdk/runtime";
49
+ ## SDK Methods
103
50
 
104
- export const MyComposition = ({ artifact }: { artifact: any }) => {
105
- return <MotionGraphicsSlot artifact={artifact} />;
106
- };
107
- ```
51
+ | Method | HTTP | Endpoint | Purpose |
52
+ | ---------------------- | ------ | ---------------------------- | ----------------------------------------------- |
53
+ | `generate()` | `POST` | `/api/generate` | Generate a composition |
54
+ | `generateStream()` | `POST` | `/api/generate` | Stream generation output with `streaming: true` |
55
+ | `edit()` | `POST` | `/api/edit` | Edit existing code |
56
+ | `generateAsync()` | `POST` | `/api/generate/async` | Queue a generation job |
57
+ | `getGenerationJob()` | `GET` | `/api/generate/async/:jobId` | Read generation job state |
58
+ | `pollGenerationJob()` | `GET` | `/api/generate/async/:jobId` | Wait for generation completion |
59
+ | `editAsync()` | `POST` | `/api/edit/async` | Queue an edit job |
60
+ | `getEditJob()` | `GET` | `/api/edit/async/:jobId` | Read edit job state |
61
+ | `pollEditJob()` | `GET` | `/api/edit/async/:jobId` | Wait for edit completion |
62
+ | `render()` | `POST` | `/api/render/render` | Start a Remotion Lambda render |
63
+ | `getRenderProgress()` | `POST` | `/api/render/progress` | Fetch render progress |
64
+ | `pollRenderProgress()` | `POST` | `/api/render/progress` | Wait for render completion |
108
65
 
109
- Start a Remotion Lambda render:
110
-
111
- ```ts
112
- const render = await client.render({
113
- inputProps: {
114
- code: generated.code,
115
- durationInFrames: generated.artifact.composition.durationInFrames,
116
- fps: generated.artifact.composition.fps,
117
- },
118
- threadId: generated.thread?.id,
119
- });
120
-
121
- const progress = await client.pollRenderProgress({
122
- id: render.renderId,
123
- bucketName: render.bucketName,
124
- });
125
- ```
126
-
127
- Successful renders consume `0.1` credit when the final video is returned.
128
-
129
- ## Getting Access
130
-
131
- To use the hosted product, create an account in [Remotion Studio](https://remotionstudio.io).
132
-
133
- To generate, edit, or render compositions through the hosted product, you also need active access to Remotion Studio credits or a subscription plan.
134
-
135
- For programmatic usage:
136
-
137
- 1. Sign in to Remotion Studio
138
- 2. Open `Settings -> API Tokens`
139
- 3. Create a token
140
- 4. Use it as a bearer token in the SDK client
141
-
142
- The plaintext token is shown only once.
143
-
144
- ## What The SDK Returns
145
-
146
- You do not import generated files directly.
147
-
148
- Instead:
149
-
150
- 1. Call the API with `@remotion-studio/sdk`
151
- 2. Receive a JSON payload containing `artifact`
152
- 3. Pass `artifact` into `@remotion-studio/sdk/runtime`
153
-
154
- The artifact is the stable contract between generation and playback.
155
-
156
- ## Core API
157
-
158
- ### Generate
159
-
160
- ```ts
161
- const generated = await client.generate({
162
- prompt: "A clean fintech dashboard animation with sliding cards",
163
- reasoningEffort: "high",
164
- });
165
- ```
166
-
167
- #### Presets
168
-
169
- Pass a `presetId` to generate compositions using a predefined style template:
66
+ ## Generate
170
67
 
171
68
  ```ts
172
69
  const generated = await client.generate({
173
- prompt: "A product showcase with smooth transitions",
174
- presetId: "preset-abc123",
70
+ prompt: "A cinematic product hero reveal with dramatic lighting",
71
+ reasoningEffort: "none",
175
72
  });
176
73
  ```
177
74
 
178
- The response includes preset information in the metadata:
75
+ Request fields:
179
76
 
180
- ```ts
181
- console.log(generated.metadata.preset);
182
- // { id: "preset-abc123", name: "Corporate Minimal", source: "builtin" | "custom" }
183
- ```
184
-
185
- Presets are created and managed in the Remotion Studio UI. Builtin presets are provided by Remotion Studio. Custom presets are user-created templates that encode style preferences, animation patterns, and design choices.
77
+ - `prompt: string`
78
+ - `presetId?: string`
79
+ - `model?: string`
80
+ - `reasoningEffort?: "none" | "low" | "medium" | "high" | "xhigh"`
81
+ - `frameImages?: string[]`
186
82
 
187
- ### Edit
83
+ ## Edit
188
84
 
189
85
  ```ts
190
86
  const edited = await client.edit({
191
- prompt: "Use a brighter palette and add more depth",
87
+ prompt: "Make it faster, cleaner, and more typography-driven",
192
88
  currentCode: generated.code,
193
89
  threadId: generated.thread?.id,
194
90
  });
195
91
  ```
196
92
 
197
- ### Stream
93
+ Common request fields:
94
+
95
+ - `prompt: string`
96
+ - `currentCode: string`
97
+ - `threadId?: string`
98
+ - `conversationHistory?: { role: "user" | "assistant"; content: string; attachedImages?: string[] }[]`
99
+ - `hasManualEdits?: boolean`
100
+ - `errorCorrection?: { error: string; source?: "compilation" | "runtime" | "generation"; attemptNumber: number; maxAttempts: number; failedEdit?: { description: string; old_string: string; new_string: string; lineNumber?: number } }`
101
+ - `previouslyUsedSkills?: string[]`
102
+ - `frameImages?: string[]`
103
+ - `model?: string`
104
+ - `reasoningEffort?: "none" | "low" | "medium" | "high" | "xhigh"`
105
+
106
+ ## Stream Generation
198
107
 
199
108
  ```ts
200
109
  const result = await client.generateStream(
@@ -205,9 +114,15 @@ const result = await client.generateStream(
205
114
  onMetadata: (metadata) => {
206
115
  console.log(metadata);
207
116
  },
117
+ onReasoningStart: () => {
118
+ console.log("reasoning started");
119
+ },
208
120
  onReasoning: (reasoning) => {
209
121
  console.log(reasoning);
210
122
  },
123
+ onTextStart: () => {
124
+ console.log("code started");
125
+ },
211
126
  onCode: (partialCode) => {
212
127
  console.log(partialCode);
213
128
  },
@@ -217,14 +132,9 @@ const result = await client.generateStream(
217
132
 
218
133
  ## Async Jobs
219
134
 
220
- Use async jobs for:
135
+ Use async methods for long-running generations or edits.
221
136
 
222
- - high-reasoning generations
223
- - server-to-server automation
224
- - long-running edits
225
- - webhook-driven integrations
226
-
227
- Queue a generation:
137
+ ### Queue A Generation
228
138
 
229
139
  ```ts
230
140
  const job = await client.generateAsync({
@@ -244,56 +154,151 @@ const generated = await client.pollGenerationJob(job.id, {
244
154
  });
245
155
  ```
246
156
 
247
- Queue an edit:
157
+ ### Read A Generation Job
158
+
159
+ ```ts
160
+ const jobState = await client.getGenerationJob(job.id);
161
+ ```
162
+
163
+ ### Queue An Edit
248
164
 
249
165
  ```ts
250
- const job = await client.editAsync({
166
+ const editJob = await client.editAsync({
251
167
  prompt: "Add more contrast and speed up the transitions",
252
168
  currentCode: generated.code,
253
169
  threadId: generated.thread?.id,
254
170
  });
255
171
 
256
- const edited = await client.pollEditJob(job.id);
172
+ const edited = await client.pollEditJob(editJob.id);
257
173
  ```
258
174
 
259
- If you provide a webhook, Remotion Studio sends the terminal job payload to your callback URL after completion or failure.
175
+ ### Read An Edit Job
260
176
 
261
- Webhook authentication is handled by caller-provided headers. Remotion Studio forwards those headers when delivering the callback.
177
+ ```ts
178
+ const editJobState = await client.getEditJob(editJob.id);
179
+ ```
262
180
 
263
- There is no built-in webhook signature mechanism.
181
+ Webhook headers are caller-owned. Remotion Studio forwards them when delivering the callback.
264
182
 
265
- The recommended pattern is:
183
+ ## Render
184
+
185
+ Start a render:
266
186
 
267
187
  ```ts
268
- await client.generateAsync({
269
- prompt: "...",
270
- webhook: {
271
- url: "https://your-app.example.com/remotionstudio/webhook",
272
- headers: {
273
- Authorization: "Bearer your-app-owned-callback-token",
274
- },
188
+ const render = await client.render({
189
+ inputProps: {
190
+ code: generated.code,
191
+ durationInFrames: generated.artifact.composition.durationInFrames,
192
+ fps: generated.artifact.composition.fps,
275
193
  },
194
+ threadId: generated.thread?.id,
276
195
  });
277
196
  ```
278
197
 
279
- Remotion Studio may include neutral metadata headers such as `X-RemotionStudio-Job-Id` and `X-RemotionStudio-Job-Type`, but it does not sign, mutate, wrap, or replace caller-provided webhook headers.
198
+ Check progress once:
280
199
 
281
- ## Local Dev And Production
200
+ ```ts
201
+ const progress = await client.getRenderProgress({
202
+ id: render.renderId,
203
+ bucketName: render.bucketName,
204
+ });
205
+ ```
282
206
 
283
- The async API contract stays the same across environments:
207
+ Poll until done:
284
208
 
285
- - local `next dev`: jobs are stored in the database and processed by a local runner
286
- - Vercel preview/production: jobs are stored in the database and executed through Vercel Workflow
209
+ ```ts
210
+ const completed = await client.pollRenderProgress(
211
+ {
212
+ id: render.renderId,
213
+ bucketName: render.bucketName,
214
+ },
215
+ {
216
+ intervalMs: 2000,
217
+ timeoutMs: 10 * 60 * 1000,
218
+ },
219
+ );
287
220
 
288
- In both cases:
221
+ console.log(completed.url);
222
+ ```
289
223
 
290
- - polling endpoints remain the source of truth
291
- - webhooks receive the same terminal payload shape
292
- - transient webhook failures are retried
224
+ ## Responses
225
+
226
+ `generate()` and `edit()` return:
227
+
228
+ - `code`
229
+ - `summary`
230
+ - `metadata`
231
+ - `artifact`
232
+ - `thread?`
233
+
234
+ The `artifact` is the stable runtime contract for playback and rendering.
293
235
 
294
236
  ## Runtime
295
237
 
296
- Use `@remotion-studio/sdk/runtime` when you want to render returned artifacts inside a Remotion project.
238
+ `@remotion-studio/sdk/runtime` exports:
239
+
240
+ - `MotionGraphicsSlot`
241
+ - `MotionGraphicsComposition`
242
+ - `calculateMotionGraphicsMetadata`
243
+ - `compileMotionGraphicsArtifact`
244
+
245
+ The runtime executes generated code inside your app process. Treat returned artifacts as trusted code only.
246
+
247
+ ### Render Inside An Existing Composition
248
+
249
+ Use `MotionGraphicsSlot` when you want to place a generated artifact inside your own composition tree.
250
+
251
+ ```tsx
252
+ import { AbsoluteFill } from "remotion";
253
+ import {
254
+ MotionGraphicsSlot,
255
+ type MotionGraphicsArtifact,
256
+ } from "@remotion-studio/sdk/runtime";
257
+
258
+ export const MyComposition = ({
259
+ artifact,
260
+ }: {
261
+ artifact: MotionGraphicsArtifact;
262
+ }) => {
263
+ return (
264
+ <AbsoluteFill>
265
+ <MotionGraphicsSlot artifact={artifact} />
266
+ </AbsoluteFill>
267
+ );
268
+ };
269
+ ```
270
+
271
+ ### Render In `@remotion/player`
272
+
273
+ ```tsx
274
+ import { Player } from "@remotion/player";
275
+ import {
276
+ MotionGraphicsComposition,
277
+ type MotionGraphicsArtifact,
278
+ } from "@remotion-studio/sdk/runtime";
279
+
280
+ export const ArtifactPlayer = ({
281
+ artifact,
282
+ }: {
283
+ artifact: MotionGraphicsArtifact;
284
+ }) => {
285
+ return (
286
+ <Player
287
+ component={MotionGraphicsComposition}
288
+ inputProps={{ artifact }}
289
+ durationInFrames={artifact.composition.durationInFrames}
290
+ fps={artifact.composition.fps}
291
+ compositionWidth={artifact.composition.width}
292
+ compositionHeight={artifact.composition.height}
293
+ controls
294
+ />
295
+ );
296
+ };
297
+ ```
298
+
299
+ ### Register As A Remotion Composition
300
+
301
+ Use `MotionGraphicsComposition` with `calculateMotionGraphicsMetadata` when the artifact should define the composition dimensions and timing.
297
302
 
298
303
  ```tsx
299
304
  import { Composition } from "remotion";
@@ -319,51 +324,51 @@ export const RemotionRoot = ({ artifact }: MotionGraphicsCompositionProps) => {
319
324
  };
320
325
  ```
321
326
 
322
- The runtime expects a normal Remotion project with the peer dependencies installed, including `react`, `remotion`, `three`, `@babel/standalone`, `@remotion/lottie`, `@remotion/shapes`, `@remotion/three`, and `@remotion/transitions`.
323
-
324
- ## Render API
327
+ ### Runtime Props
325
328
 
326
- If your Remotion Studio instance is configured with Remotion Lambda, the SDK also supports:
329
+ Both `MotionGraphicsSlot` and `MotionGraphicsComposition` accept:
327
330
 
328
- - `client.render()` to queue a render
329
- - `client.getRenderProgress()` to fetch the latest render state
330
- - `client.pollRenderProgress()` to wait until the render completes
331
+ - `artifact: MotionGraphicsArtifact`
332
+ - `componentProps?: Record<string, unknown>`
331
333
 
332
- The render endpoints return the Remotion Lambda render identifiers and progress state, including the final output URL when rendering is done.
334
+ `componentProps` is forwarded to the generated component at runtime.
333
335
 
334
- ## Model And Credit Notes
336
+ ## Runtime Dependencies
335
337
 
336
- The base model is controlled by the Remotion Studio admin. External clients should usually send only `reasoningEffort`.
337
- Supported `reasoningEffort` values are `none`, `low`, `medium`, `high`, and `xhigh`. Use `none` to explicitly disable reasoning.
338
+ If you only use the API client from `@remotion-studio/sdk`, you do not need any runtime dependencies.
338
339
 
339
- Current credit usage is:
340
+ If you use `@remotion-studio/sdk/runtime`, the package installs its runtime helper dependencies for you.
340
341
 
341
- - default request or `reasoningEffort: "none"`: 1 credit
342
- - successful render completion: 0.1 credit
343
- - `low`: 2 credits
344
- - `medium`: 3 credits
345
- - `high`: 4 credits
346
- - `xhigh`: 5 credits
342
+ You still need to use it inside a normal React + Remotion app, and install `@remotion/player` separately if you want to use the player example above.
347
343
 
348
- Legacy clients may still send `model: "provider/model:medium"`, but only the reasoning suffix is used.
344
+ ## Errors
349
345
 
350
- ## API Docs
346
+ API failures throw `RemotionStudioError`.
351
347
 
352
- If you run your own Remotion Studio instance, the generated API reference is available at:
348
+ Useful fields:
353
349
 
354
- ```text
355
- https://your-remotionstudio-domain.com/api-docs
356
- ```
350
+ - `message`
351
+ - `type`
352
+ - `status?`
353
+ - `failedEdit?`
354
+ - `availableCredits?`
355
+ - `requiredCredits?`
357
356
 
358
- ## Links
357
+ ## API Docs
359
358
 
360
- - Website: [remotionstudio.io](https://remotionstudio.io)
361
- - Product: [Remotion Studio](https://remotionstudio.io)
362
- - Repository: [github.com/prismosoft/remotionstudio](https://github.com/prismosoft/remotionstudio)
359
+ - Hosted API reference: [remotionstudio.io/api-docs](https://remotionstudio.io/api-docs)
363
360
 
364
361
  ## Package Exports
365
362
 
366
363
  ```ts
367
- import { createRemotionStudioClient } from "@remotion-studio/sdk";
368
- import { MotionGraphicsSlot } from "@remotion-studio/sdk/runtime";
364
+ import {
365
+ createRemotionStudioClient,
366
+ RemotionStudioError,
367
+ } from "@remotion-studio/sdk";
368
+ import {
369
+ MotionGraphicsSlot,
370
+ MotionGraphicsComposition,
371
+ calculateMotionGraphicsMetadata,
372
+ compileMotionGraphicsArtifact,
373
+ } from "@remotion-studio/sdk/runtime";
369
374
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion-studio/sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "private": false,
5
5
  "description": "Official Remotion Studio package for generating, editing, playing, and rendering AI-powered Remotion compositions.",
6
6
  "packageManager": "bun@1.3.3",
@@ -39,16 +39,32 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "peerDependencies": {
42
+ "dependencies": {
43
43
  "@babel/standalone": "^7.28.5",
44
+ "@react-three/fiber": "^9.1.0",
44
45
  "@remotion/lottie": "^4.0.429",
45
46
  "@remotion/shapes": "^4.0.429",
46
47
  "@remotion/three": "^4.0.429",
47
48
  "@remotion/transitions": "^4.0.429",
48
- "react": "^19.2.1",
49
- "remotion": "^4.0.429",
49
+ "lottie-web": "^5.13.0",
50
50
  "three": "^0.178.0"
51
51
  },
52
+ "peerDependencies": {
53
+ "react": "^19.2.1",
54
+ "react-dom": "^19.2.1",
55
+ "remotion": "^4.0.429"
56
+ },
57
+ "peerDependenciesMeta": {
58
+ "react": {
59
+ "optional": true
60
+ },
61
+ "react-dom": {
62
+ "optional": true
63
+ },
64
+ "remotion": {
65
+ "optional": true
66
+ }
67
+ },
52
68
  "scripts": {
53
69
  "build": "rm -rf dist && tsc -p tsconfig.build.json",
54
70
  "test": "bun test ./test",