> For the complete documentation index, see [llms.txt](https://imagineclub.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://imagineclub.gitbook.io/docs/elizaos/plugin-imagine.md).

# plugin-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](https://github.com/onbonsai/plugin-imagine).

```
yarn add @onbonsai/plugin-imagine
```

## Exports

These are the main exports available from the package

```typescript
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.

```ts
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
```
