# Create Chat Completion — Cerebras

> Create a chat completion with Cerebras AI. See the documentation

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

## Description

Create a chat completion with Cerebras AI. [See the documentation](https://inference-docs.cerebras.ai/api-reference/chat-completions)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `model` | `string` | Yes | The model to use for the request Options are loaded from the connected account. |
| `message` | `string` | Yes | The message to send to the model |
| `maxCompletionTokens` | `integer` | No | The maximum number of tokens that can be generated in the completion. The total length of input tokens and generated tokens is limited by the model's context length. |
| `stream` | `boolean` | No | If set, partial message deltas will be sent. Tokens will be sent as data-only server-sent events as they become available |
| `seed` | `integer` | No | If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result |
| `stop` | `string` | No | Up to 4 sequences, separated by commas, where the API will stop generating further tokens. The returned text will not contain the stop sequence |
| `temperature` | `string` | No | What sampling temperature to use, between 0 and 1.5. Higher values (e.g., 0.8) will make the output more random, while lower values (e.g., 0.2) will make it more focused and deterministic |
| `topP` | `string` | No | An alternative to sampling with temperature, called nucleus sampling, where the model considers the tokens with top_p probability mass |
| `toolChoice` | `string` | No | Controls which (if any) tool is called by the model |
| `tools` | `object` | No | A list of tools the model may call. See the documentation for more information |
| `user` | `string` | No | A unique identifier representing your end-user, which can help Cerebras to monitor and detect abuse |
| `logprobs` | `boolean` | No | Whether to return log probabilities of the output tokens or not |
| `topLogprobs` | `integer` | No | An integer between 0 and 20 specifying the number of most likely tokens to return at each token position, each with an associated log probability |

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

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: "cerebras-create-chat-completion",
  arguments: {
    model: "Model",
    message: "Message",
  },
})
```

**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: "cerebras-create-chat-completion",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    cerebras: { authProvisionId: "apn_xxxxxxx" },
    model: "Model",
    message: "Message",
  },
})

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": "cerebras-create-chat-completion",
    "configured_props": {
      "cerebras": { "authProvisionId": "apn_xxxxxxx" },
      "model": "Model",
      "message": "Message"
    }
  }'
```

---

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