|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +import { APIResource } from '../core/resource'; |
| 4 | +import { APIPromise } from '../core/api-promise'; |
| 5 | +import { RequestOptions } from '../internal/request-options'; |
| 6 | +import { path } from '../internal/utils/path'; |
| 7 | + |
| 8 | +export class Videos extends APIResource { |
| 9 | + /** |
| 10 | + * Create a video |
| 11 | + * |
| 12 | + * @example |
| 13 | + * ```ts |
| 14 | + * const video = await client.videos.create({ |
| 15 | + * model: 'model', |
| 16 | + * }); |
| 17 | + * ``` |
| 18 | + */ |
| 19 | + create(body: VideoCreateParams, options?: RequestOptions): APIPromise<VideoCreateResponse> { |
| 20 | + return this._client.post('/videos', { body, defaultBaseURL: 'https://api.together.xyz/v2', ...options }); |
| 21 | + } |
| 22 | + |
| 23 | + /** |
| 24 | + * Fetch video metadata |
| 25 | + * |
| 26 | + * @example |
| 27 | + * ```ts |
| 28 | + * const video = await client.videos.retrieve('id'); |
| 29 | + * ``` |
| 30 | + */ |
| 31 | + retrieve(id: string, options?: RequestOptions): APIPromise<VideoRetrieveResponse> { |
| 32 | + return this._client.get(path`/videos/${id}`, { |
| 33 | + defaultBaseURL: 'https://api.together.xyz/v2', |
| 34 | + ...options, |
| 35 | + }); |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +export interface VideoCreateResponse { |
| 40 | + /** |
| 41 | + * Unique identifier for the video job. |
| 42 | + */ |
| 43 | + id?: string; |
| 44 | +} |
| 45 | + |
| 46 | +/** |
| 47 | + * Structured information describing a generated video job. |
| 48 | + */ |
| 49 | +export interface VideoRetrieveResponse { |
| 50 | + /** |
| 51 | + * Unique identifier for the video job. |
| 52 | + */ |
| 53 | + id: string; |
| 54 | + |
| 55 | + /** |
| 56 | + * Unix timestamp (seconds) for when the job was created. |
| 57 | + */ |
| 58 | + created_at: number; |
| 59 | + |
| 60 | + /** |
| 61 | + * The video generation model that produced the job. |
| 62 | + */ |
| 63 | + model: string; |
| 64 | + |
| 65 | + /** |
| 66 | + * Duration of the generated clip in seconds. |
| 67 | + */ |
| 68 | + seconds: string; |
| 69 | + |
| 70 | + /** |
| 71 | + * The resolution of the generated video. |
| 72 | + */ |
| 73 | + size: string; |
| 74 | + |
| 75 | + /** |
| 76 | + * Current lifecycle status of the video job. |
| 77 | + */ |
| 78 | + status: 'in_progress' | 'completed' | 'failed'; |
| 79 | + |
| 80 | + /** |
| 81 | + * Unix timestamp (seconds) for when the job completed, if finished. |
| 82 | + */ |
| 83 | + completed_at?: number; |
| 84 | + |
| 85 | + /** |
| 86 | + * Error payload that explains why generation failed, if applicable. |
| 87 | + */ |
| 88 | + error?: VideoRetrieveResponse.Error; |
| 89 | + |
| 90 | + /** |
| 91 | + * The object type, which is always video. |
| 92 | + */ |
| 93 | + object?: 'video'; |
| 94 | + |
| 95 | + /** |
| 96 | + * Available upon completion, the outputs provides the cost charged and the hosted |
| 97 | + * url to access the video |
| 98 | + */ |
| 99 | + outputs?: VideoRetrieveResponse.Outputs; |
| 100 | +} |
| 101 | + |
| 102 | +export namespace VideoRetrieveResponse { |
| 103 | + /** |
| 104 | + * Error payload that explains why generation failed, if applicable. |
| 105 | + */ |
| 106 | + export interface Error { |
| 107 | + message: string; |
| 108 | + |
| 109 | + code?: string; |
| 110 | + } |
| 111 | + |
| 112 | + /** |
| 113 | + * Available upon completion, the outputs provides the cost charged and the hosted |
| 114 | + * url to access the video |
| 115 | + */ |
| 116 | + export interface Outputs { |
| 117 | + /** |
| 118 | + * The cost of generated video charged to the owners account. |
| 119 | + */ |
| 120 | + cost: number; |
| 121 | + |
| 122 | + /** |
| 123 | + * URL hosting the generated video |
| 124 | + */ |
| 125 | + video_url: string; |
| 126 | + } |
| 127 | +} |
| 128 | + |
| 129 | +export interface VideoCreateParams { |
| 130 | + /** |
| 131 | + * The model to be used for the video creation request. |
| 132 | + */ |
| 133 | + model: string; |
| 134 | + |
| 135 | + /** |
| 136 | + * Frames per second. Defaults to 24. |
| 137 | + */ |
| 138 | + fps?: number; |
| 139 | + |
| 140 | + /** |
| 141 | + * Array of images to guide video generation, like keyframes. If size 1, starting |
| 142 | + * frame, if size 2, starting and ending frame, if more than 2 then frame must be |
| 143 | + * specified |
| 144 | + */ |
| 145 | + frame_images?: Array<VideoCreateParams.FrameImage>; |
| 146 | + |
| 147 | + /** |
| 148 | + * Controls how closely the video generation follows your prompt. Higher values |
| 149 | + * make the model adhere more strictly to your text description, while lower values |
| 150 | + * allow more creative freedom. guidence_scale affects both visual content and |
| 151 | + * temporal consistency.Recommended range is 6.0-10.0 for most video models. Values |
| 152 | + * above 12 may cause over-guidance artifacts or unnatural motion patterns. |
| 153 | + */ |
| 154 | + guidance_scale?: number; |
| 155 | + |
| 156 | + height?: number; |
| 157 | + |
| 158 | + /** |
| 159 | + * Similar to prompt, but specifies what to avoid instead of what to include |
| 160 | + */ |
| 161 | + negative_prompt?: string; |
| 162 | + |
| 163 | + /** |
| 164 | + * Specifies the format of the output video. Defaults to MP4. |
| 165 | + */ |
| 166 | + output_format?: 'MP4' | 'WEBM'; |
| 167 | + |
| 168 | + /** |
| 169 | + * Compression quality. Defaults to 20. |
| 170 | + */ |
| 171 | + output_quality?: number; |
| 172 | + |
| 173 | + /** |
| 174 | + * Text prompt that describes the video to generate. |
| 175 | + */ |
| 176 | + prompt?: string; |
| 177 | + |
| 178 | + /** |
| 179 | + * TODO need to figure this out |
| 180 | + */ |
| 181 | + reference_images?: Array<unknown>; |
| 182 | + |
| 183 | + /** |
| 184 | + * Clip duration in seconds. |
| 185 | + */ |
| 186 | + seconds?: string; |
| 187 | + |
| 188 | + /** |
| 189 | + * Seed to use in initializing the video generation. Using the same seed allows |
| 190 | + * deterministic video generation. If not provided a random seed is generated for |
| 191 | + * each request. |
| 192 | + */ |
| 193 | + seed?: number; |
| 194 | + |
| 195 | + /** |
| 196 | + * The number of denoising steps the model performs during video generation. More |
| 197 | + * steps typically result in higher quality output but require longer processing |
| 198 | + * time. |
| 199 | + */ |
| 200 | + steps?: number; |
| 201 | + |
| 202 | + width?: number; |
| 203 | +} |
| 204 | + |
| 205 | +export namespace VideoCreateParams { |
| 206 | + export interface FrameImage { |
| 207 | + frame: number | 'first' | 'last'; |
| 208 | + |
| 209 | + /** |
| 210 | + * idk |
| 211 | + */ |
| 212 | + input_image: string; |
| 213 | + } |
| 214 | +} |
| 215 | + |
| 216 | +export declare namespace Videos { |
| 217 | + export { |
| 218 | + type VideoCreateResponse as VideoCreateResponse, |
| 219 | + type VideoRetrieveResponse as VideoRetrieveResponse, |
| 220 | + type VideoCreateParams as VideoCreateParams, |
| 221 | + }; |
| 222 | +} |
0 commit comments