# Image Inference — Runware

> Request an image inference task to be processed by the Runware API. See the documentation.

- Key: `runware-image-inference`
- Type: Action (Write)
- Version: 0.0.2
- App: Runware (`runware`) — https://pipedream.com/apps/runware.md
- This page (HTML): https://pipedream.com/apps/runware/actions/image-inference
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/runware/actions/image-inference/image-inference.mjs

## Description

Request an image inference task to be processed by the Runware API. [See the documentation](https://docs.runware.ai/en/image-inference/api-reference).

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `structure` | `string` | Yes | The structure of the task to be processed. |
| `model` | `string` | Yes | This identifier is a unique string that represents a specific model. You can find the AIR identifier of the model you want to use in our Model Explorer, which is a tool that allows you to search for models based on their characteristics. More information about the AIR system can be found in the Models page. Eg. civitai:78605@83390. |
| `positivePrompt` | `string` | Yes | A positive prompt is a text instruction to guide the model on generating the image. It is usually a sentence or a paragraph that provides positive guidance for the task. This parameter is essential to shape the desired results. For example, if the positive prompt is dragon drinking coffee, the model will generate an image of a dragon drinking coffee. The more detailed the prompt, the more accurate the results. The length of the prompt must be between 4 and 2000 characters. |
| `height` | `integer` | Yes | Used to define the height dimension of the generated image. Certain models perform better with specific dimensions. The value must be divisible by 64, eg: 512, 576, 640 ... 2048. |
| `width` | `integer` | Yes | Used to define the width dimension of the generated image. Certain models perform better with specific dimensions. The value must be divisible by 64, eg: 512, 576, 640 ... 2048. |
| `uploadEndpoint` | `string` | No | This parameter allows you to specify a URL to which the generated image will be uploaded as binary image data using the HTTP PUT method. For example, an S3 bucket URL can be used as the upload endpoint. When the image is ready, it will be uploaded to the specified URL. |
| `checkNSFW` | `boolean` | No | This parameter is used to enable or disable the NSFW check. When enabled, the API will check if the image contains NSFW (not safe for work) content. This check is done using a pre-trained model that detects adult content in images. When the check is enabled, the API will return NSFWContent: true in the response object if the image is flagged as potentially sensitive content. If the image is not flagged, the API will return NSFWContent: false. If this parameter is not used, the parameter NSFWContent will not be included in the response object. Adds 0.1 seconds to image inference time and incurs additional costs. The NSFW filter occasionally returns false positives and very rarely false negatives. |
| `includeCost` | `boolean` | No | If set to true, the cost to perform the task will be included in the response object. Defaults to false. |
| `scheduler` | `string` | No | An scheduler is a component that manages the inference process. Different schedulers can be used to achieve different results like more detailed images, faster inference, or more accurate results. The default scheduler is the one that the model was trained with, but you can choose a different one to get different results. Schedulers are explained in more detail in the Schedulers page. |
| `seed` | `string` | No | A seed is a value used to randomize the image generation. If you want to make images reproducible (generate the same image multiple times), you can use the same seed value. When requesting multiple images with the same seed, the seed will be incremented by 1 (+1) for each image generated. Min: 0 Max: 9223372036854776000. Defaults to Random. |
| `numberResults` | `integer` | No | The number of images to generate from the specified prompt. If Seed is set, it will be incremented by 1 (+1) for each image generated. |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "runware",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "runware-image-inference",
  arguments: {
    structure: "Structure",
    model: "Model",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "runware-image-inference",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    runware: { authProvisionId: "apn_xxxxxxx" },
    structure: "Structure",
    model: "Model",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "runware-image-inference",
    "configured_props": {
      "runware": { "authProvisionId": "apn_xxxxxxx" },
      "structure": "Structure",
      "model": "Model"
    }
  }'
```

---

- App: https://pipedream.com/apps/runware.md · All apps: https://pipedream.com/apps
