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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://imagineclub.gitbook.io/docs/elizaos/plugin-imagine.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
