videov1

import videov1 "pocketone.dev/ext/contracts/llm/video/v1"

Package videov1 is the llm.video/v1 contract: a model makes a video from a prompt (and a first frame). Like music it's a job: create starts it (or waits for it, with wait), get follows it, content fetches its files.

A wire contract at /api/_c/llm.video/v1. In pb_hooks it's $llm.video.

Source: ext/contracts/llm/video/v1.

Variables

var Contract = extkit.NewContract[Video]("llm.video/v1", extkit.One).JS(extkit.JSHooks, nil).JSTypes(jsTypes)

Contract is llm.video/v1.

var W = extkit.NewWire(Contract, "llm", func(inner Video, g *extkit.Guard[Video]) Video {
	return &guardVideo{inner, g}
},
	extkit.Op[Video]{
		Name:   "create",
		Desc:   "Starts making a video. With Wait it returns once the job is done (or failed); otherwise at once, to follow with Get. A done job lists how many files it made (Outputs); Content fetches each.",
		Method: "POST",
		Path:   "create",
		In:     reflect.TypeOf(CreateInput{}),
		Out:    extkit.OutJSON,
		Invoke: func(ctx context.Context, impl Video, a extkit.Auth, req extkit.OpRequest) (any, error) {
			var in CreateInput
			if err := extkit.DecodeInput(req.JSON, &in); err != nil {
				return nil, err
			}
			return impl.Create(ctx, a, in)
		},
	},
	extkit.Op[Video]{
		Name:   "get",
		Desc:   "Says how a job is going.",
		Method: "POST",
		Path:   "get",
		Scope:  "llm:read",
		In:     reflect.TypeOf(llm.JobRef{}),
		Out:    extkit.OutJSON,
		Invoke: func(ctx context.Context, impl Video, a extkit.Auth, req extkit.OpRequest) (any, error) {
			var in llm.JobRef
			if err := extkit.DecodeInput(req.JSON, &in); err != nil {
				return nil, err
			}
			return impl.Get(ctx, a, in)
		},
	},
	extkit.Op[Video]{
		Name:   "content",
		Desc:   "Fetches one of a done job's files.",
		Method: "POST",
		Path:   "content",
		Scope:  "llm:read",
		In:     reflect.TypeOf(llm.ContentInput{}),
		Out:    extkit.OutJSON,
		Invoke: func(ctx context.Context, impl Video, a extkit.Auth, req extkit.OpRequest) (any, error) {
			var in llm.ContentInput
			if err := extkit.DecodeInput(req.JSON, &in); err != nil {
				return nil, err
			}
			return impl.Content(ctx, a, in)
		},
	},
	extkit.Op[Video]{
		Name:   "models",
		Desc:   "Lists the video models of every provider in Settings → LLM.",
		Method: "GET",
		Path:   "models",
		Scope:  "llm:read",
		In:     reflect.TypeOf(llm.ModelsInput{}),
		Out:    extkit.OutJSON,
		Invoke: func(ctx context.Context, impl Video, a extkit.Auth, req extkit.OpRequest) (any, error) {
			var in llm.ModelsInput
			if err := extkit.DecodeQuery(req.Query, &in); err != nil {
				return nil, err
			}
			return impl.Models(ctx, a, in)
		},
	},
)

W is llm.video/v1's wire side: routes at /api/_c/llm.video/v1/<op>, action hooks, MCP tools and the client.

Functions

OnContent

func OnContent(owner any, fn func(e *extkit.CallEvent, in *llm.ContentInput) error)

OnContent binds fn to content calls on owner (an app, or a host's scope for calls the host answers). Call e.Next() to continue; return an error to refuse. in is the call's input; changes reach the provider.

OnCreate

func OnCreate(owner any, fn func(e *extkit.CallEvent, in *CreateInput) error)

OnCreate binds fn to create calls on owner (an app, or a host's scope for calls the host answers). Call e.Next() to continue; return an error to refuse. in is the call's input; changes reach the provider.

OnGet

func OnGet(owner any, fn func(e *extkit.CallEvent, in *llm.JobRef) error)

OnGet binds fn to get calls on owner (an app, or a host's scope for calls the host answers). Call e.Next() to continue; return an error to refuse. in is the call's input; changes reach the provider.

OnModels

func OnModels(owner any, fn func(e *extkit.CallEvent, in *llm.ModelsInput) error)

OnModels binds fn to models calls on owner (an app, or a host's scope for calls the host answers). Call e.Next() to continue; return an error to refuse. in is the call's input; changes reach the provider.

Types

Client

type Client struct {
	// contains filtered or unexported fields
}

Client is llm.video/v1 over HTTP, for the CLI and other apps. It implements Video; the token it was made with is the credential, so the extkit.Auth argument is ignored.

NewClient

func NewClient(baseURL, token string, hc *http.Client) *Client

NewClient calls llm.video/v1 on the app at baseURL with token (a PocketBase auth token or an API token).

Client.Content

func (c *Client) Content(ctx context.Context, _ extkit.Auth, in llm.ContentInput) (llm.File, error)

Client.Create

func (c *Client) Create(ctx context.Context, _ extkit.Auth, in CreateInput) (llm.Job, error)

Client.Get

func (c *Client) Get(ctx context.Context, _ extkit.Auth, in llm.JobRef) (llm.Job, error)

Client.Models

func (c *Client) Models(ctx context.Context, _ extkit.Auth, in llm.ModelsInput) (llm.Models, error)

CreateInput

type CreateInput struct {
	Model  string `json:"model"` // "provider/model", required
	Prompt string `json:"prompt"`
	// Image is a first frame to start from, for models that take one.
	Image   *llm.File `json:"image,omitempty"`
	Seconds float64   `json:"seconds,omitempty"`
	Size    string    `json:"size,omitempty"` // "1280x720"
	// AspectRatio is "16:9", "9:16"... for models that take one instead of a size.
	AspectRatio string `json:"aspectRatio,omitempty"`
	// Wait is how long to wait for the job, as a duration ("10m"); "" returns at once.
	Wait    string      `json:"wait,omitempty"`
	Options llm.Options `json:"options,omitempty"`
}

CreateInput is the video to make.

Video

type Video interface {
	// Create starts making a video. With Wait it returns once the job is done (or failed); otherwise at once, to
	// follow with Get. A done job lists how many files it made (Outputs); Content fetches each.
	//
	//op: POST create
	Create(ctx context.Context, a extkit.Auth, in CreateInput) (llm.Job, error)
	// Get says how a job is going.
	//
	//op: POST get scope=llm:read
	Get(ctx context.Context, a extkit.Auth, in llm.JobRef) (llm.Job, error)
	// Content fetches one of a done job's files.
	//
	//op: POST content scope=llm:read
	Content(ctx context.Context, a extkit.Auth, in llm.ContentInput) (llm.File, error)
	// Models lists the video models of every provider in Settings → LLM.
	//
	//op: GET models scope=llm:read
	Models(ctx context.Context, a extkit.Auth, in llm.ModelsInput) (llm.Models, error)
}

Video makes videos.