# Chat — Cohere

> Generates a text response to a user message. See the documentation

- Key: `cohere_platform-chat`
- Type: Action (Write)
- Version: 0.0.2
- App: Cohere (`cohere_platform`) — https://pipedream.com/apps/cohere-platform.md
- This page (HTML): https://pipedream.com/apps/cohere-platform/actions/chat
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/cohere_platform/actions/chat/chat.mjs

## Description

Generates a text response to a user message. [See the documentation](https://docs.cohere.com/reference/chat)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `message` | `string` | Yes | Text input for the model to respond to. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker, Private Deployments |
| `model` | `string` | No | Defaults to command-r-plus. The name of a compatible Cohere model or the ID of a fine-tuned model. Compatible Deployments: Cohere Platform, Private Deployments. |
| `temperature` | `string` | No | Must be between 0 and 1.0 inclusive that tunes the degree of randomness in generation. Lower temperatures mean less random generations, and higher temperatures mean more random generations. Randomness can be further maximized by increasing the value of the P parameter. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker, Private Deployments See Temperature for more details. |
| `maxTokens` | `integer` | No | The maximum number of tokens the model will generate as part of the response. Note: Setting a low value may result in incomplete generations. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker, Private Deployments. See BPE Tokens for more details. |
| `k` | `integer` | No | Ensures only the top K most likely tokens are considered for generation at each step. Defaults to 0, min value of 0, max value of 500. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker, Private Deployments |
| `p` | `string` | No | Ensures that only the most likely tokens, with total probability mass of P, are considered for generation at each step. If both K and P are enabled, P acts after K. Defaults to 0.75. min value of 0.01, max value of 0.99. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker, Private Deployments |
| `stopSequences` | `string[]` | No | A list of up to 5 strings that the model will use to stop generation. If the model generates a string that matches any of the strings in the list, it will stop generating tokens and return the generated text up to that point not including the stop sequence. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker, Private Deployments |
| `frequencyPenalty` | `string` | No | Defaults to 0.0, min value of 0.0, max value of 1.0. Used to reduce repetitiveness of generated tokens. The higher the value, the stronger a penalty is applied to previously present tokens, proportional to how many times they have already appeared in the prompt or prior generation. Compatible Deployments: Cohere Platform, Azure, AWS Sagemaker, Private Deployments |

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

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: "cohere_platform-chat",
  arguments: {
    message: "Message",
    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: "cohere_platform-chat",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    cohere_platform: { authProvisionId: "apn_xxxxxxx" },
    message: "Message",
    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": "cohere_platform-chat",
    "configured_props": {
      "cohere_platform": { "authProvisionId": "apn_xxxxxxx" },
      "message": "Message",
      "model": "Model"
    }
  }'
```

---

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