VideoGeneration - Go SDK

VideoGeneration method reference

The Go SDK and docs are currently in beta. Report issues on GitHub.

Overview

Video Generation endpoints

Available Operations

Generate

Submits a video generation request and returns a polling URL to check status

Example Usage

1package main
2
3import(
4 "context"
5 "os"
6 openrouter "github.com/OpenRouterTeam/go-sdk"
7 "github.com/OpenRouterTeam/go-sdk/models/components"
8 "log"
9)
10
11func main() {
12 ctx := context.Background()
13
14 s := openrouter.New(
15 openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")),
16 )
17
18 res, err := s.VideoGeneration.Generate(ctx, components.VideoGenerationRequest{
19 AspectRatio: components.AspectRatioOneHundredAndSixtyNine.ToPointer(),
20 Duration: openrouter.Pointer[int64](8),
21 Model: "google/veo-3.1",
22 Prompt: "A serene mountain landscape at sunset",
23 Resolution: components.ResolutionSevenHundredAndTwentyp.ToPointer(),
24 })
25 if err != nil {
26 log.Fatal(err)
27 }
28 if res != nil {
29 // handle response
30 }
31}

Parameters

ParameterTypeRequiredDescription
ctxcontext.Context✔️The context to use for the request.
requestcomponents.VideoGenerationRequest✔️The request object to use for the request.
opts[]operations.OptionThe options for this request.

Response

*components.VideoGenerationResponse, error

Errors

Error TypeStatus CodeContent Type
sdkerrors.BadRequestResponseError400application/json
sdkerrors.UnauthorizedResponseError401application/json
sdkerrors.PaymentRequiredResponseError402application/json
sdkerrors.NotFoundResponseError404application/json
sdkerrors.TooManyRequestsResponseError429application/json
sdkerrors.InternalServerResponseError500application/json
sdkerrors.APIError4XX, 5XX*/*

GetGeneration

Returns job status and content URLs when completed

Example Usage

1package main
2
3import(
4 "context"
5 "os"
6 openrouter "github.com/OpenRouterTeam/go-sdk"
7 "log"
8)
9
10func main() {
11 ctx := context.Background()
12
13 s := openrouter.New(
14 openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")),
15 )
16
17 res, err := s.VideoGeneration.GetGeneration(ctx, "job-abc123")
18 if err != nil {
19 log.Fatal(err)
20 }
21 if res != nil {
22 // handle response
23 }
24}

Parameters

ParameterTypeRequiredDescriptionExample
ctxcontext.Context✔️The context to use for the request.
jobIDstring✔️N/Ajob-abc123
opts[]operations.OptionThe options for this request.

Response

*components.VideoGenerationResponse, error

Errors

Error TypeStatus CodeContent Type
sdkerrors.UnauthorizedResponseError401application/json
sdkerrors.NotFoundResponseError404application/json
sdkerrors.InternalServerResponseError500application/json
sdkerrors.APIError4XX, 5XX*/*

GetVideoContent

Streams the generated video content from the upstream provider

Example Usage

1package main
2
3import(
4 "context"
5 "os"
6 openrouter "github.com/OpenRouterTeam/go-sdk"
7 "github.com/OpenRouterTeam/go-sdk/optionalnullable"
8 "log"
9)
10
11func main() {
12 ctx := context.Background()
13
14 s := openrouter.New(
15 openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")),
16 )
17
18 res, err := s.VideoGeneration.GetVideoContent(ctx, "job-abc123", optionalnullable.From(openrouter.Pointer[int64](0)))
19 if err != nil {
20 log.Fatal(err)
21 }
22 if res != nil {
23 // handle response
24 }
25}

Parameters

ParameterTypeRequiredDescriptionExample
ctxcontext.Context✔️The context to use for the request.
jobIDstring✔️N/Ajob-abc123
indexoptionalnullable.OptionalNullable[int64]N/A0
opts[]operations.OptionThe options for this request.

Response

io.ReadCloser, error

Errors

Error TypeStatus CodeContent Type
sdkerrors.BadRequestResponseError400application/json
sdkerrors.UnauthorizedResponseError401application/json
sdkerrors.NotFoundResponseError404application/json
sdkerrors.InternalServerResponseError500application/json
sdkerrors.BadGatewayResponseError502application/json
sdkerrors.APIError4XX, 5XX*/*

ListVideosModels

Returns a list of all available video generation models and their properties

Example Usage

1package main
2
3import(
4 "context"
5 "os"
6 openrouter "github.com/OpenRouterTeam/go-sdk"
7 "log"
8)
9
10func main() {
11 ctx := context.Background()
12
13 s := openrouter.New(
14 openrouter.WithSecurity(os.Getenv("OPENROUTER_API_KEY")),
15 )
16
17 res, err := s.VideoGeneration.ListVideosModels(ctx)
18 if err != nil {
19 log.Fatal(err)
20 }
21 if res != nil {
22 // handle response
23 }
24}

Parameters

ParameterTypeRequiredDescription
ctxcontext.Context✔️The context to use for the request.
opts[]operations.OptionThe options for this request.

Response

*components.VideoModelsListResponse, error

Errors

Error TypeStatus CodeContent Type
sdkerrors.BadRequestResponseError400application/json
sdkerrors.InternalServerResponseError500application/json
sdkerrors.APIError4XX, 5XX*/*