# Create Chat — Llama AI

> Creates a new chat. See the documentation

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

## Description

Creates a new chat. [See the documentation](https://docs.llama-api.com/api-reference/endpoint/create)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `messages` | `string[]` | Yes | A collection of messages that form the ongoing conversation. Each message should be a JSON string. |
| `functions` | `string[]` | No | A list of functions for which the model can generate JSON inputs. Each function should be a JSON string. |
| `stream` | `boolean` | No | When this option is enabled, the model will send partial message updates, similar to ChatGPT. Tokens will be transmitted as data-only server-sent events as they become available, and the streaming will conclude with a data: [DONE] marker. |
| `functionCall` | `string` | No | This parameter governs the model's response to function calls. Choosing "none" indicates that the model will not invoke any functions and will respond directly to the end-user. |

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

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: "llama_ai-create-chat",
  arguments: {
    messages: ["Messages"],
    functions: ["Functions"],
  },
})
```

**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: "llama_ai-create-chat",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    llama_ai: { authProvisionId: "apn_xxxxxxx" },
    messages: ["Messages"],
    functions: ["Functions"],
  },
})

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": "llama_ai-create-chat",
    "configured_props": {
      "llama_ai": { "authProvisionId": "apn_xxxxxxx" },
      "messages": ["Messages"],
      "functions": ["Functions"]
    }
  }'
```

---

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