Skip to content

Commit cbd8766

Browse files
feat(api): Update with gen4_turbo, org endpoint (#96)
1 parent 527e17b commit cbd8766

File tree

9 files changed

+222
-24
lines changed

9 files changed

+222
-24
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 3
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runwayml%2Frunwayml-256f9e345a6be31b0c9fc494e70c5ff977f52316c2a7b07f388154522e74d7bb.yml
3-
openapi_spec_hash: 209a527f6ae5a1c2ed3a0e105df23277
4-
config_hash: b2e67f7e840f18a352ace32dc0778534
1+
configured_endpoints: 4
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runwayml%2Frunwayml-8572445174f75794a6c3bdd3ffacd7ea80b140bb5ffbf59656e7da3668228249.yml
3+
openapi_spec_hash: 8b99d38d0511b6f4291a7d39c12d580e
4+
config_hash: 77ce816c37172a537f337abfaf2d65a9

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const client = new RunwayML({
2828

2929
async function main() {
3030
const imageToVideo = await client.imageToVideo.create({
31-
model: 'gen3a_turbo',
31+
model: 'gen4_turbo',
3232
promptImage: 'https://example.com/assets/bunny.jpg',
3333
promptText: 'The bunny is eating a carrot',
3434
});
@@ -53,7 +53,7 @@ const client = new RunwayML({
5353

5454
async function main() {
5555
const params: RunwayML.ImageToVideoCreateParams = {
56-
model: 'gen3a_turbo',
56+
model: 'gen4_turbo',
5757
promptImage: 'https://example.com/assets/bunny.jpg',
5858
promptText: 'The bunny is eating a carrot',
5959
};
@@ -76,7 +76,7 @@ a subclass of `APIError` will be thrown:
7676
async function main() {
7777
const imageToVideo = await client.imageToVideo
7878
.create({
79-
model: 'gen3a_turbo',
79+
model: 'gen4_turbo',
8080
promptImage: 'https://example.com/assets/bunny.jpg',
8181
promptText: 'The bunny is eating a carrot',
8282
})
@@ -123,7 +123,7 @@ const client = new RunwayML({
123123
});
124124

125125
// Or, configure per-request:
126-
await client.imageToVideo.create({ model: 'gen3a_turbo', promptImage: 'https://example.com/assets/bunny.jpg', promptText: 'The bunny is eating a carrot' }, {
126+
await client.imageToVideo.create({ model: 'gen4_turbo', promptImage: 'https://example.com/assets/bunny.jpg', promptText: 'The bunny is eating a carrot' }, {
127127
maxRetries: 5,
128128
});
129129
```
@@ -140,7 +140,7 @@ const client = new RunwayML({
140140
});
141141

142142
// Override per-request:
143-
await client.imageToVideo.create({ model: 'gen3a_turbo', promptImage: 'https://example.com/assets/bunny.jpg', promptText: 'The bunny is eating a carrot' }, {
143+
await client.imageToVideo.create({ model: 'gen4_turbo', promptImage: 'https://example.com/assets/bunny.jpg', promptText: 'The bunny is eating a carrot' }, {
144144
timeout: 5 * 1000,
145145
});
146146
```
@@ -163,7 +163,7 @@ const client = new RunwayML();
163163

164164
const response = await client.imageToVideo
165165
.create({
166-
model: 'gen3a_turbo',
166+
model: 'gen4_turbo',
167167
promptImage: 'https://example.com/assets/bunny.jpg',
168168
promptText: 'The bunny is eating a carrot',
169169
})
@@ -173,7 +173,7 @@ console.log(response.statusText); // access the underlying Response object
173173

174174
const { data: imageToVideo, response: raw } = await client.imageToVideo
175175
.create({
176-
model: 'gen3a_turbo',
176+
model: 'gen4_turbo',
177177
promptImage: 'https://example.com/assets/bunny.jpg',
178178
promptText: 'The bunny is eating a carrot',
179179
})
@@ -285,7 +285,7 @@ const client = new RunwayML({
285285
// Override per-request:
286286
await client.imageToVideo.create(
287287
{
288-
model: 'gen3a_turbo',
288+
model: 'gen4_turbo',
289289
promptImage: 'https://example.com/assets/bunny.jpg',
290290
promptText: 'The bunny is eating a carrot',
291291
},

api.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,13 @@ Types:
1818
Methods:
1919

2020
- <code title="post /v1/image_to_video">client.imageToVideo.<a href="./src/resources/image-to-video.ts">create</a>({ ...params }) -> ImageToVideoCreateResponse</code>
21+
22+
# Organization
23+
24+
Types:
25+
26+
- <code><a href="./src/resources/organization.ts">OrganizationRetrieveResponse</a></code>
27+
28+
Methods:
29+
30+
- <code title="get /v1/organization">client.organization.<a href="./src/resources/organization.ts">retrieve</a>() -> OrganizationRetrieveResponse</code>

src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
ImageToVideoCreateParams,
1111
ImageToVideoCreateResponse,
1212
} from './resources/image-to-video';
13+
import { Organization, OrganizationRetrieveResponse } from './resources/organization';
1314
import { TaskRetrieveResponse, Tasks } from './resources/tasks';
1415

1516
export interface ClientOptions {
@@ -140,6 +141,7 @@ export class RunwayML extends Core.APIClient {
140141

141142
tasks: API.Tasks = new API.Tasks(this);
142143
imageToVideo: API.ImageToVideo = new API.ImageToVideo(this);
144+
organization: API.Organization = new API.Organization(this);
143145

144146
protected override defaultQuery(): Core.DefaultQuery | undefined {
145147
return this._options.defaultQuery;
@@ -180,6 +182,7 @@ export class RunwayML extends Core.APIClient {
180182

181183
RunwayML.Tasks = Tasks;
182184
RunwayML.ImageToVideo = ImageToVideo;
185+
RunwayML.Organization = Organization;
183186
export declare namespace RunwayML {
184187
export type RequestOptions = Core.RequestOptions;
185188

@@ -190,6 +193,8 @@ export declare namespace RunwayML {
190193
type ImageToVideoCreateResponse as ImageToVideoCreateResponse,
191194
type ImageToVideoCreateParams as ImageToVideoCreateParams,
192195
};
196+
197+
export { Organization as Organization, type OrganizationRetrieveResponse as OrganizationRetrieveResponse };
193198
}
194199

195200
export { toFile, fileFromPath } from './uploads';

src/resources/image-to-video.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export interface ImageToVideoCreateParams {
2727
/**
2828
* The model variant to use.
2929
*/
30-
model: 'gen3a_turbo';
30+
model: 'gen4_turbo' | 'gen3a_turbo';
3131

3232
/**
3333
* A HTTPS URL or data URI containing an encoded image to be used as the first
@@ -43,20 +43,22 @@ export interface ImageToVideoCreateParams {
4343

4444
promptText?: string;
4545

46-
ratio?: '1280:768' | '768:1280';
46+
ratio?:
47+
| '1280:720'
48+
| '720:1280'
49+
| '1104:832'
50+
| '832:1104'
51+
| '960:960'
52+
| '1584:672'
53+
| '1280:768'
54+
| '768:1280';
4755

4856
/**
4957
* If unspecified, a random number is chosen. Varying the seed integer is a way to
5058
* get different results for the same other request parameters. Using the same seed
5159
* integer for an identical request will produce similar results.
5260
*/
5361
seed?: number;
54-
55-
/**
56-
* A boolean indicating whether or not the output video will contain a Runway
57-
* watermark.
58-
*/
59-
watermark?: boolean;
6062
}
6163

6264
export namespace ImageToVideoCreateParams {
@@ -65,6 +67,8 @@ export namespace ImageToVideoCreateParams {
6567
* The position of the image in the output video. "first" will use the image as the
6668
* first frame of the video, "last" will use the image as the last frame of the
6769
* video.
70+
*
71+
* "last" is currently supported for `gen3a_turbo` only.
6872
*/
6973
position: 'first' | 'last';
7074

src/resources/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export {
55
type ImageToVideoCreateResponse,
66
type ImageToVideoCreateParams,
77
} from './image-to-video';
8+
export { Organization, type OrganizationRetrieveResponse } from './organization';
89
export { Tasks, type TaskRetrieveResponse } from './tasks';

src/resources/organization.ts

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { APIResource } from '../resource';
4+
import * as Core from '../core';
5+
6+
export class Organization extends APIResource {
7+
/**
8+
* Get usage tier and credit balance information about the organization associated
9+
* with the API key used to make the request.
10+
*/
11+
retrieve(options?: Core.RequestOptions): Core.APIPromise<OrganizationRetrieveResponse> {
12+
return this._client.get('/v1/organization', options);
13+
}
14+
}
15+
16+
export interface OrganizationRetrieveResponse {
17+
/**
18+
* The number of credits remaining in the organization account.
19+
*/
20+
creditBalance: number;
21+
22+
/**
23+
* Limits associated with the organization's tier.
24+
*/
25+
tier: OrganizationRetrieveResponse.Tier;
26+
27+
/**
28+
* Usage data for the organization.
29+
*/
30+
usage: OrganizationRetrieveResponse.Usage;
31+
}
32+
33+
export namespace OrganizationRetrieveResponse {
34+
/**
35+
* Limits associated with the organization's tier.
36+
*/
37+
export interface Tier {
38+
/**
39+
* The maximum number of credits that can be purchased in a month.
40+
*/
41+
maxMonthlyCreditSpend: number;
42+
43+
/**
44+
* An object containing model-specific limits. Each key represents a model.
45+
*/
46+
models: Tier.Models;
47+
}
48+
49+
export namespace Tier {
50+
/**
51+
* An object containing model-specific limits. Each key represents a model.
52+
*/
53+
export interface Models {
54+
/**
55+
* Limits associated with the gen3a_turbo model.
56+
*/
57+
gen3a_turbo?: Models.Gen3aTurbo;
58+
59+
/**
60+
* Limits associated with the gen4_turbo model.
61+
*/
62+
gen4_turbo?: Models.Gen4Turbo;
63+
}
64+
65+
export namespace Models {
66+
/**
67+
* Limits associated with the gen3a_turbo model.
68+
*/
69+
export interface Gen3aTurbo {
70+
/**
71+
* The maximum number of generations that can be run concurrently for this model.
72+
*/
73+
maxConcurrentGenerations: number;
74+
75+
/**
76+
* The maximum number of generations that can be created each day for this model.
77+
*/
78+
maxDailyGenerations: number;
79+
}
80+
81+
/**
82+
* Limits associated with the gen4_turbo model.
83+
*/
84+
export interface Gen4Turbo {
85+
/**
86+
* The maximum number of generations that can be run concurrently for this model.
87+
*/
88+
maxConcurrentGenerations: number;
89+
90+
/**
91+
* The maximum number of generations that can be created each day for this model.
92+
*/
93+
maxDailyGenerations: number;
94+
}
95+
}
96+
}
97+
98+
/**
99+
* Usage data for the organization.
100+
*/
101+
export interface Usage {
102+
/**
103+
* Usage data for each model.
104+
*/
105+
models: Usage.Models;
106+
}
107+
108+
export namespace Usage {
109+
/**
110+
* Usage data for each model.
111+
*/
112+
export interface Models {
113+
/**
114+
* Usage data for the gen3a_turbo model.
115+
*/
116+
gen3a_turbo?: Models.Gen3aTurbo;
117+
118+
/**
119+
* Usage data for the gen4_turbo model.
120+
*/
121+
gen4_turbo?: Models.Gen4Turbo;
122+
}
123+
124+
export namespace Models {
125+
/**
126+
* Usage data for the gen3a_turbo model.
127+
*/
128+
export interface Gen3aTurbo {
129+
/**
130+
* The number of generations that have been run for this model in the past day.
131+
*/
132+
dailyGenerations: number;
133+
}
134+
135+
/**
136+
* Usage data for the gen4_turbo model.
137+
*/
138+
export interface Gen4Turbo {
139+
/**
140+
* The number of generations that have been run for this model in the past day.
141+
*/
142+
dailyGenerations: number;
143+
}
144+
}
145+
}
146+
}
147+
148+
export declare namespace Organization {
149+
export { type OrganizationRetrieveResponse as OrganizationRetrieveResponse };
150+
}

tests/api-resources/image-to-video.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const client = new RunwayML({
1111
describe('resource imageToVideo', () => {
1212
test('create: only required params', async () => {
1313
const responsePromise = client.imageToVideo.create({
14-
model: 'gen3a_turbo',
14+
model: 'gen4_turbo',
1515
promptImage: 'https://example.com',
1616
});
1717
const rawResponse = await responsePromise.asResponse();
@@ -25,13 +25,12 @@ describe('resource imageToVideo', () => {
2525

2626
test('create: required and optional params', async () => {
2727
const response = await client.imageToVideo.create({
28-
model: 'gen3a_turbo',
28+
model: 'gen4_turbo',
2929
promptImage: 'https://example.com',
3030
duration: 5,
3131
promptText: 'promptText',
32-
ratio: '1280:768',
32+
ratio: '1280:720',
3333
seed: 0,
34-
watermark: true,
3534
});
3635
});
3736
});
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import RunwayML from '@runwayml/sdk';
4+
import { Response } from 'node-fetch';
5+
6+
const client = new RunwayML({
7+
apiKey: 'My API Key',
8+
baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010',
9+
});
10+
11+
describe('resource organization', () => {
12+
test('retrieve', async () => {
13+
const responsePromise = client.organization.retrieve();
14+
const rawResponse = await responsePromise.asResponse();
15+
expect(rawResponse).toBeInstanceOf(Response);
16+
const response = await responsePromise;
17+
expect(response).not.toBeInstanceOf(Response);
18+
const dataAndResponse = await responsePromise.withResponse();
19+
expect(dataAndResponse.data).toBe(response);
20+
expect(dataAndResponse.response).toBe(rawResponse);
21+
});
22+
23+
test('retrieve: request options instead of params are passed correctly', async () => {
24+
// ensure the request options are being passed correctly by passing an invalid HTTP method in order to cause an error
25+
await expect(client.organization.retrieve({ path: '/_stainless_unknown_path' })).rejects.toThrow(
26+
RunwayML.NotFoundError,
27+
);
28+
});
29+
});

0 commit comments

Comments
 (0)