For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
ModelsChatRankingsDocs
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
    • Overview
    • Usage for Agents
  • TypeScript SDK
    • Overview
  • Python SDK
    • Overview
  • Go SDK
      • Analytics
      • APIKeys
      • Byok
      • Chat
      • Credits
      • Embeddings
      • Endpoints
      • Generations
      • Guardrails
      • OAuth
      • Observability
      • Organization
      • Presets
      • Providers
      • Rerank
      • Beta.Responses
      • Transcriptions
      • Speech
      • VideoGeneration
      • Workspaces
  • DevTools
    • Overview
    • Migrating to @openrouter/agent
LogoLogo
ModelsChatRankingsDocs
On this page
  • Overview
  • Available Operations
  • Generate
  • Example Usage
  • Parameters
  • Response
  • Errors
  • GetGeneration
  • Example Usage
  • Parameters
  • Response
  • Errors
  • GetVideoContent
  • Example Usage
  • Parameters
  • Response
  • Errors
  • ListVideosModels
  • Example Usage
  • Parameters
  • Response
  • Errors
Go SDKAPI Reference

VideoGeneration - Go SDK

VideoGeneration method reference
Was this page helpful?
Previous

Workspaces - Go SDK

Workspaces method reference
Next
Built with

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

Overview

Video Generation endpoints

Available Operations

  • Generate - Submit a video generation request
  • GetGeneration - Poll video generation status
  • GetVideoContent - Download generated video content
  • ListVideosModels - List all video generation models

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.Option➖The 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.Option➖The 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.Option➖The 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.Option➖The options for this request.

Response

*components.VideoModelsListResponse, error

Errors

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