> ## Documentation Index
> Fetch the complete documentation index at: https://docs.meetdarwin.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Stream chat replies with the TypeScript SDK

> Talk to your Darwin agent from your own app with @meetdarwin/api: create a chat session, send a message and wait for the reply, or stream it with sendStream and textDeltas.

Talk to your Darwin agent from your own app, Slack, WhatsApp or a voice bot. The key needs the `chat:write` scope. Darwin keeps the transcript; you send only what the visitor said. How sessions, actions and allowances work: [Chat API](https://docs.meetdarwin.ai/api-reference/chat-api.md).

```ts theme={null}
const session = await darwin.chat.sessions.create({
  visitor: { email: "ada@example.com", name: "Ada" }, // treated as verified: you hold the key
  channel: "app",
  context: { plan: "enterprise", seats: 40 },
});

// Wait for the whole reply.
const reply = await darwin.chat.sessions.send(session.id, { text: "Can I book a demo?" });
console.log(reply.message.text);
for (const action of reply.actions) {
  if (action.type === "booking_offered") showBookingButton(action.booking_url);
}

// Or stream it as it is written.
const stream = await darwin.chat.sessions.sendStream(session.id, { text: "What does it cost?" });
for await (const delta of stream.textDeltas()) process.stdout.write(delta);
```

A `ChatStream` can also be iterated for every parsed chunk of the AI SDK UI message stream (`start`, `text-delta`, `tool-input-available`, `tool-output-available`, `finish`, `error`…), or read in one go with `await stream.finalText()`. Call `stream.abort()` to stop.

`sendStream` sends no automatic `Idempotency-Key`, because the API holds an idempotent response back until it is complete in order to store it. For the same reason it is retried only after a 429. `send` gets a key and the usual retries.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.