# Modify Image — DreamStudio (Stable Diffusion)

> Modify an image based on a text prompt. See the documentation

- Key: `dreamstudio-modify-image`
- Type: Action (Read-only)
- Version: 1.0.3
- App: DreamStudio (Stable Diffusion) (`dreamstudio`) — https://pipedream.com/apps/dreamstudio.md
- This page (HTML): https://pipedream.com/apps/dreamstudio/actions/modify-image
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/dreamstudio/actions/modify-image/modify-image.mjs

## Description

Modify an image based on a text prompt. [See the documentation](https://platform.stability.ai/docs/api-reference#tag/v1generation/operation/imageToImage)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `organizationId` | `string` | Yes | The id of the organization. Options are loaded from the connected account. |
| `engineId` | `string` | Yes | The id of the engine. Options are loaded from the connected account. |
| `textPrompts` | `string[]` | Yes | An array of valid JSON objects to use for generation. The JSON object must have the text and the weight. e.g.{"text": "A lighthouse on a cliff", "weight": 0.5} |
| `initImage` | `string` | Yes | Provide either a file URL or a path to a file in the /tmp directory (for example, /tmp/example.png) |
| `cfgScale` | `integer` | No | How strictly the diffusion process adheres to the prompt text (higher values keep your image closer to your prompt). |
| `clipGuidancePreset` | `string` | No | Clip Guidance Preset |
| `sampler` | `string` | No | Which sampler to use for the diffusion process. If this value is omitted we'll automatically select an appropriate sampler for you. |
| `samples` | `integer` | No | Number of images to generate |
| `seed` | `integer` | No | Random noise seed (omit this option or use 0 for a random seed). |
| `steps` | `integer` | No | Number od diffusion steps to run. |
| `stylePreset` | `string` | No | Pass in a style preset to guide the image model towards a particular style. |
| `extras` | `object` | No | Extra parameters passed to the engine. These parameters are used for in-development or experimental features and may charge without werning, so please use with caution. |
| `initImageMode` | `string` | No | Used to control how much influence the init image has on the result. |
| `syncDir` | `dir` | Yes | SyncDir |

## 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": "dreamstudio",
      },
    },
  },
)

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: "dreamstudio-modify-image",
  arguments: {
    organizationId: "Organization Id",
    engineId: "Engine Id",
  },
})
```

**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: "dreamstudio-modify-image",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    dreamstudio: { authProvisionId: "apn_xxxxxxx" },
    organizationId: "Organization Id",
    engineId: "Engine Id",
  },
})

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": "dreamstudio-modify-image",
    "configured_props": {
      "dreamstudio": { "authProvisionId": "apn_xxxxxxx" },
      "organizationId": "Organization Id",
      "engineId": "Engine Id"
    }
  }'
```

---

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