# Classify Text — Cohere

> This action makes a prediction about which label fits the specified text inputs best. See the documentation

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

## Description

This action makes a prediction about which label fits the specified text inputs best. [See the documentation](https://docs.cohere.com/reference/classify-1)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `inputs` | `string[]` | Yes | Represents a list of queries to be classified, each entry must not be empty. The maximum is 96 inputs. |
| `model` | `string` | No | The identifier of the model. Currently available models are embed-multilingual-v2.0, embed-english-light-v2.0, and embed-english-v2.0 (default). Smaller light models are faster, while larger models will perform better. Fine-tuned models can also be supplied with their full ID. |
| `preset` | `string` | No | The ID of a custom playground preset. You can create presets in the playground. If you use a preset, all other parameters become optional, and any included parameters will override the preset's parameters. |
| `truncate` | `string` | No | One of NONE\|START\|END to specify how the API will handle inputs longer than the maximum token length. Passing START will discard the start of the input. END will discard the end of the input. In both cases, input is discarded until the remaining input is exactly the maximum input token length for the model. If NONE is selected, when the input exceeds the maximum input token length an error will be returned. |
| `numExamples` | `integer` | Yes | To make a prediction, Classify uses provided examples of text + label pairs. Specify the number of examples to provide. Each example is a text string and its associated label/class. At least 2 unique labels must be provided and each label should have at least 2 different examples. |

## 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-classify-text",
  arguments: {
    inputs: ["Inputs"],
    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-classify-text",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    cohere_platform: { authProvisionId: "apn_xxxxxxx" },
    inputs: ["Inputs"],
    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-classify-text",
    "configured_props": {
      "cohere_platform": { "authProvisionId": "apn_xxxxxxx" },
      "inputs": ["Inputs"],
      "model": "Model"
    }
  }'
```

---

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