# Send Prompt — Writer

> Generate text with Writer's chat completion API. Use this whenever the user asks you to write, draft, compose, generate, rewrite, summarize, translate, or brainstorm any text with Writer — subject lines, announcements, welcome messages…

- Key: `writer-send-prompt`
- Type: Action (Write)
- Version: 1.0.1
- App: Writer (`writer`) — https://pipedream.com/apps/writer.md
- This page (HTML): https://pipedream.com/apps/writer/actions/send-prompt
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/writer/actions/send-prompt/send-prompt.mjs

## Description

Generate text with Writer's chat completion API. Use this whenever the user asks you to **write, draft, compose, generate, rewrite, summarize, translate, or brainstorm** any text with Writer — subject lines, announcements, welcome messages, poems, copy, headlines, translations, and similar. Route these requests through Writer (which applies the team's models) rather than answering from your own knowledge. Pass the conversation as `messages`; optionally choose a `model` (defaults to `palmyra-x5`, a strong general-purpose model — creative writing included). Use **List Models** to discover other model ids available to the account. For questions grounded in your team's own documents, use **Ask Knowledge Graph** instead. Example: to draft a welcome message, call with `messages=[{ "role": "user", "content": "Draft a 2-sentence welcome message for new visitors." }]` and `model="palmyra-x5"` -> returns an OpenAI-shaped response whose `choices[0].message.content` holds the generated text. [See the documentation](https://dev.writer.com/api-reference/completion-api/chat-completion)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `messages` | `string` | Yes | JSON array of chat messages. Each message is { "role": ..., "content": ... } where role is one of user, assistant, system, or tool. Example: [{ "role": "system", "content": "You are a concise copywriter." }, { "role": "user", "content": "Write a 2-sentence welcome message." }]. |
| `model` | `string` | No | The model id to generate with. Defaults to palmyra-x5 (recommended for most tasks, creative writing included). Use List Models to see all model ids available to the account. |
| `maxTokens` | `integer` | No | Maximum number of tokens the model may generate in the response. |
| `temperature` | `string` | No | Controls randomness/creativity, typically between 0 and 2 (default 1). Higher values (e.g. 1.5) produce more varied text; lower values (e.g. 0.2) produce more deterministic, conservative output. |
| `topP` | `string` | No | Nucleus-sampling threshold between 0 and 1. Only tokens whose cumulative probability exceeds this value are considered. An alternative to temperature — generally set one or the other, not both. Example: 0.9. |
| `n` | `integer` | No | How many completions to generate in a single request (default 1). Each is returned as a separate entry in the choices array. Example: 3 to get three alternatives to choose from. |
| `stop` | `string[]` | No | One or more sequences that, when generated, stop the model from producing further text. Example: ["\n\n", "END"]. |
| `logprobs` | `boolean` | No | Whether to return the log probabilities of the output tokens (default false). |
| `tools` | `string` | No | JSON array of tool definitions the model may use, following Writer's tool schema. Use custom function tools and/or one built-in tool (graph, llm, translation, vision, or web_search) — only one built-in type per request. Example: [{ "type": "function", "function": { "name": "get_weather", "parameters": { "type": "object", "properties": { "city": { "type": "string" } } } } }]. |
| `toolChoice` | `string` | No | How the model decides to call tools. One of the keywords auto (default), none, or required, OR a JSON object forcing a specific function, e.g. { "type": "function", "function": { "name": "get_weather" } }. |
| `responseFormat` | `string` | No | JSON object specifying the output format (supported on palmyra-x4 and palmyra-x5). Default is plain text. For structured output pass a json_schema, e.g. { "type": "json_schema", "json_schema": { "name": "result", "schema": { "type": "object", "properties": { "title": { "type": "string" } } } } }. |

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

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: "writer-send-prompt",
  arguments: {
    messages: "Messages",
    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: "writer-send-prompt",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    writer: { authProvisionId: "apn_xxxxxxx" },
    messages: "Messages",
    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": "writer-send-prompt",
    "configured_props": {
      "writer": { "authProvisionId": "apn_xxxxxxx" },
      "messages": "Messages",
      "model": "Model"
    }
  }'
```

---

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