plugin-imagine

This package allows any ElizaOS agent to pay for media generations on Imagine.

Installation

In your EllizaOS agent, you can run the following command to install the plugin

elizaos plugins add @onbonsai/plugin-imagine

And add it to your agent's character file

{
  "plugins": ["@onbonsai/plugin-imagine"]
}

You can also just install the package and use the imports. Check the repo here.

yarn add @onbonsai/plugin-imagine

Exports

These are the main exports available from the package

import { 
    GenerationService
} from "@elizaos/plugin-imagine";
  • GenerationService: create content from a prompt and optional template data

Usage

The only required field is prompt. Optional templateData supports video options (defaults are sensible), and you may pass an image as a URL, base64 data URL, or File.

import { privateKeyToAccount } from "viem/accounts";
import { GenerationService, type GenerationResponse } from "@onbonsai/plugin-imagine";

const account = privateKeyToAccount(process.env.EVM_PRIVATE_KEY as `0x${string}`);
const generationService = new GenerationService(account, "base", process.env.BASE_RPC_URL as string);

const prompt = "A futuristic character waves in a neon cyberpunk city";

// Triggers x402 payment before the generation request is processed
const generationResponse = await generationService.create({
  prompt,
  // Optional image input (URL | base64 data URL | File)
  image: "https://example.com/pfp.jpg",
  // Optional video parameters (all optional; defaults apply)
  templateData: {
    videoModel: "sora", // default
    duration: 8,
    soraVideoId: "vid_abc123", // if remixing a previously
  },
});

const { id, generation, templateData } = generationResponse as GenerationResponse;

// Use:
// - generation.video for the video
// - generation.image for the cover image
// - templateData.soraVideoId to remix in a future request

Last updated