@@ -31,8 +31,7 @@ import (
3131// automatically. You should not instantiate this service directly, and instead use
3232// the [NewVideoService] method instead.
3333type VideoService struct {
34- Options []option.RequestOption
35- Character VideoCharacterService
34+ Options []option.RequestOption
3635}
3736
3837// NewVideoService generates a new service that applies the given options to each
@@ -41,7 +40,6 @@ type VideoService struct {
4140func NewVideoService (opts ... option.RequestOption ) (r VideoService ) {
4241 r = VideoService {}
4342 r .Options = opts
44- r .Character = NewVideoCharacterService (opts ... )
4543 return
4644}
4745
@@ -112,6 +110,14 @@ func (r *VideoService) Delete(ctx context.Context, videoID string, opts ...optio
112110 return res , err
113111}
114112
113+ // Create a character from an uploaded video.
114+ func (r * VideoService ) NewCharacter (ctx context.Context , body VideoNewCharacterParams , opts ... option.RequestOption ) (res * VideoNewCharacterResponse , err error ) {
115+ opts = slices .Concat (r .Options , opts )
116+ path := "videos/characters"
117+ err = requestconfig .ExecuteNewRequest (ctx , http .MethodPost , path , body , & res , opts ... )
118+ return res , err
119+ }
120+
115121// Download the generated video bytes or a derived preview asset.
116122//
117123// Streams the rendered video content for the specified video job.
@@ -144,6 +150,18 @@ func (r *VideoService) Extend(ctx context.Context, body VideoExtendParams, opts
144150 return res , err
145151}
146152
153+ // Fetch a character.
154+ func (r * VideoService ) GetCharacter (ctx context.Context , characterID string , opts ... option.RequestOption ) (res * VideoGetCharacterResponse , err error ) {
155+ opts = slices .Concat (r .Options , opts )
156+ if characterID == "" {
157+ err = errors .New ("missing required character_id parameter" )
158+ return nil , err
159+ }
160+ path := fmt .Sprintf ("videos/characters/%s" , characterID )
161+ err = requestconfig .ExecuteNewRequest (ctx , http .MethodGet , path , nil , & res , opts ... )
162+ return res , err
163+ }
164+
147165// Create a remix of a completed video using a refreshed prompt.
148166func (r * VideoService ) Remix (ctx context.Context , videoID string , body VideoRemixParams , opts ... option.RequestOption ) (res * Video , err error ) {
149167 opts = slices .Concat (r .Options , opts )
@@ -156,6 +174,21 @@ func (r *VideoService) Remix(ctx context.Context, videoID string, body VideoRemi
156174 return res , err
157175}
158176
177+ type ImageInputReferenceParam struct {
178+ FileID param.Opt [string ] `json:"file_id,omitzero"`
179+ // A fully qualified URL or base64-encoded data URL.
180+ ImageURL param.Opt [string ] `json:"image_url,omitzero"`
181+ paramObj
182+ }
183+
184+ func (r ImageInputReferenceParam ) MarshalJSON () (data []byte , err error ) {
185+ type shadow ImageInputReferenceParam
186+ return param .MarshalObject (r , (* shadow )(& r ))
187+ }
188+ func (r * ImageInputReferenceParam ) UnmarshalJSON (data []byte ) error {
189+ return apijson .UnmarshalRoot (data , r )
190+ }
191+
159192// Structured information describing a generated video job.
160193type Video struct {
161194 // Unique identifier for the video job.
@@ -297,6 +330,52 @@ func (r *VideoDeleteResponse) UnmarshalJSON(data []byte) error {
297330 return apijson .UnmarshalRoot (data , r )
298331}
299332
333+ type VideoNewCharacterResponse struct {
334+ // Identifier for the character creation cameo.
335+ ID string `json:"id" api:"required"`
336+ // Unix timestamp (in seconds) when the character was created.
337+ CreatedAt int64 `json:"created_at" api:"required"`
338+ // Display name for the character.
339+ Name string `json:"name" api:"required"`
340+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
341+ JSON struct {
342+ ID respjson.Field
343+ CreatedAt respjson.Field
344+ Name respjson.Field
345+ ExtraFields map [string ]respjson.Field
346+ raw string
347+ } `json:"-"`
348+ }
349+
350+ // Returns the unmodified JSON received from the API
351+ func (r VideoNewCharacterResponse ) RawJSON () string { return r .JSON .raw }
352+ func (r * VideoNewCharacterResponse ) UnmarshalJSON (data []byte ) error {
353+ return apijson .UnmarshalRoot (data , r )
354+ }
355+
356+ type VideoGetCharacterResponse struct {
357+ // Identifier for the character creation cameo.
358+ ID string `json:"id" api:"required"`
359+ // Unix timestamp (in seconds) when the character was created.
360+ CreatedAt int64 `json:"created_at" api:"required"`
361+ // Display name for the character.
362+ Name string `json:"name" api:"required"`
363+ // JSON contains metadata for fields, check presence with [respjson.Field.Valid].
364+ JSON struct {
365+ ID respjson.Field
366+ CreatedAt respjson.Field
367+ Name respjson.Field
368+ ExtraFields map [string ]respjson.Field
369+ raw string
370+ } `json:"-"`
371+ }
372+
373+ // Returns the unmodified JSON received from the API
374+ func (r VideoGetCharacterResponse ) RawJSON () string { return r .JSON .raw }
375+ func (r * VideoGetCharacterResponse ) UnmarshalJSON (data []byte ) error {
376+ return apijson .UnmarshalRoot (data , r )
377+ }
378+
300379type VideoNewParams struct {
301380 // Text prompt that describes the video to generate.
302381 Prompt string `json:"prompt" api:"required"`
@@ -339,13 +418,13 @@ func (r VideoNewParams) MarshalMultipart() (data []byte, contentType string, err
339418//
340419// Use [param.IsOmitted] to confirm if a field is set.
341420type VideoNewParamsInputReferenceUnion struct {
342- OfFile io.Reader `json:",omitzero,inline"`
343- OfVideoNewsInputReferenceImageRefParam2 * VideoNewParamsInputReferenceImageRefParam2 `json:",omitzero,inline"`
421+ OfFile io.Reader `json:",omitzero,inline"`
422+ OfImageInputReference * ImageInputReferenceParam `json:",omitzero,inline"`
344423 paramUnion
345424}
346425
347426func (u VideoNewParamsInputReferenceUnion ) MarshalJSON () ([]byte , error ) {
348- return param .MarshalUnion (u , u .OfFile , u .OfVideoNewsInputReferenceImageRefParam2 )
427+ return param .MarshalUnion (u , u .OfFile , u .OfImageInputReference )
349428}
350429func (u * VideoNewParamsInputReferenceUnion ) UnmarshalJSON (data []byte ) error {
351430 return apijson .UnmarshalRoot (data , u )
@@ -354,27 +433,12 @@ func (u *VideoNewParamsInputReferenceUnion) UnmarshalJSON(data []byte) error {
354433func (u * VideoNewParamsInputReferenceUnion ) asAny () any {
355434 if ! param .IsOmitted (u .OfFile ) {
356435 return & u .OfFile
357- } else if ! param .IsOmitted (u .OfVideoNewsInputReferenceImageRefParam2 ) {
358- return u .OfVideoNewsInputReferenceImageRefParam2
436+ } else if ! param .IsOmitted (u .OfImageInputReference ) {
437+ return u .OfImageInputReference
359438 }
360439 return nil
361440}
362441
363- type VideoNewParamsInputReferenceImageRefParam2 struct {
364- FileID param.Opt [string ] `json:"file_id,omitzero"`
365- // A fully qualified URL or base64-encoded data URL.
366- ImageURL param.Opt [string ] `json:"image_url,omitzero"`
367- paramObj
368- }
369-
370- func (r VideoNewParamsInputReferenceImageRefParam2 ) MarshalJSON () (data []byte , err error ) {
371- type shadow VideoNewParamsInputReferenceImageRefParam2
372- return param .MarshalObject (r , (* shadow )(& r ))
373- }
374- func (r * VideoNewParamsInputReferenceImageRefParam2 ) UnmarshalJSON (data []byte ) error {
375- return apijson .UnmarshalRoot (data , r )
376- }
377-
378442type VideoListParams struct {
379443 // Identifier for the last item from the previous pagination request
380444 After param.Opt [string ] `query:"after,omitzero" json:"-"`
@@ -405,6 +469,32 @@ const (
405469 VideoListParamsOrderDesc VideoListParamsOrder = "desc"
406470)
407471
472+ type VideoNewCharacterParams struct {
473+ // Display name for this API character.
474+ Name string `json:"name" api:"required"`
475+ // Video file used to create a character.
476+ Video io.Reader `json:"video,omitzero" api:"required" format:"binary"`
477+ paramObj
478+ }
479+
480+ func (r VideoNewCharacterParams ) MarshalMultipart () (data []byte , contentType string , err error ) {
481+ buf := bytes .NewBuffer (nil )
482+ writer := multipart .NewWriter (buf )
483+ err = apiform .MarshalRoot (r , writer )
484+ if err == nil {
485+ err = apiform .WriteExtras (writer , r .ExtraFields ())
486+ }
487+ if err != nil {
488+ writer .Close ()
489+ return nil , "" , err
490+ }
491+ err = writer .Close ()
492+ if err != nil {
493+ return nil , "" , err
494+ }
495+ return buf .Bytes (), writer .FormDataContentType (), nil
496+ }
497+
408498type VideoDownloadContentParams struct {
409499 // Which downloadable asset to return. Defaults to the MP4 video.
410500 //
@@ -507,7 +597,7 @@ type VideoExtendParams struct {
507597 //
508598 // Any of "4", "8", "12".
509599 Seconds VideoSeconds `json:"seconds,omitzero" api:"required"`
510- // Reference to the completed video.
600+ // Reference to the completed video to extend .
511601 Video VideoExtendParamsVideoUnion `json:"video,omitzero" api:"required" format:"binary"`
512602 paramObj
513603}
@@ -534,23 +624,23 @@ func (r VideoExtendParams) MarshalMultipart() (data []byte, contentType string,
534624//
535625// Use [param.IsOmitted] to confirm if a field is set.
536626type VideoExtendParamsVideoUnion struct {
537- OfVideoExtendsVideoVideoReferenceInputParam * VideoExtendParamsVideoVideoReferenceInputParam `json:",omitzero,inline"`
538627 OfFile io.Reader `json:",omitzero,inline"`
628+ OfVideoExtendsVideoVideoReferenceInputParam * VideoExtendParamsVideoVideoReferenceInputParam `json:",omitzero,inline"`
539629 paramUnion
540630}
541631
542632func (u VideoExtendParamsVideoUnion ) MarshalJSON () ([]byte , error ) {
543- return param .MarshalUnion (u , u .OfVideoExtendsVideoVideoReferenceInputParam , u .OfFile )
633+ return param .MarshalUnion (u , u .OfFile , u .OfVideoExtendsVideoVideoReferenceInputParam )
544634}
545635func (u * VideoExtendParamsVideoUnion ) UnmarshalJSON (data []byte ) error {
546636 return apijson .UnmarshalRoot (data , u )
547637}
548638
549639func (u * VideoExtendParamsVideoUnion ) asAny () any {
550- if ! param .IsOmitted (u .OfVideoExtendsVideoVideoReferenceInputParam ) {
551- return u .OfVideoExtendsVideoVideoReferenceInputParam
552- } else if ! param .IsOmitted (u .OfFile ) {
640+ if ! param .IsOmitted (u .OfFile ) {
553641 return & u .OfFile
642+ } else if ! param .IsOmitted (u .OfVideoExtendsVideoVideoReferenceInputParam ) {
643+ return u .OfVideoExtendsVideoVideoReferenceInputParam
554644 }
555645 return nil
556646}
0 commit comments