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

# LangChain & Vercel AI SDK

> Native Gork tools for LangChain agents and the Vercel AI SDK.

## LangChain

`@gork/sdk` ships four `StructuredTool` tools plus two assembly helpers — `gorkTools` (aliased as `createGorkTools`) and the `GorkToolkit` class.

```bash theme={null}
npm i @gork/sdk @langchain/core zod
```

```typescript theme={null}
import { gorkTools, createGorkTools, GorkToolkit } from "@gork/sdk/langchain";

// All three are equivalent:
const toolsA = gorkTools({ apiKey: process.env.GORK_API_KEY });
const toolsB = createGorkTools({ apiKey: process.env.GORK_API_KEY });
const toolsC = new GorkToolkit({ apiKey: process.env.GORK_API_KEY }).getTools();
```

| Tool                | What it does                                                     |
| ------------------- | ---------------------------------------------------------------- |
| `gork_create_inbox` | Provision an agent inbox (`username`, `name?`)                   |
| `gork_send_email`   | Send from an inbox (`inboxId`, `to`, `subject`, `text`)          |
| `gork_read_emails`  | List mail (`inboxId?`, `threadId?`, `limit?`)                    |
| `gork_reply_email`  | Threaded reply (`inboxId`, `messageId`, `to`, `subject`, `text`) |

```typescript theme={null}
import { gorkTools } from "@gork/sdk/langchain";

const tools = gorkTools({ apiKey: process.env.GORK_API_KEY });
// Pass `tools` to your LangChain agent executor alongside your model.
```

## Vercel AI SDK

`getGorkAiTools` returns tools that drop straight into `generateText` / `streamText`. Pass a `Gork` client or `{ apiKey, baseUrl }`.

```bash theme={null}
npm i @gork/sdk ai zod
```

```typescript theme={null}
import { generateText } from "ai";
import { Gork } from "@gork/sdk";
import { getGorkAiTools } from "@gork/sdk/ai";

const gork = new Gork({ apiKey: process.env.GORK_API_KEY });

const { text } = await generateText({
  model: "openai/gpt-4o-mini",
  tools: getGorkAiTools(gork),
  prompt: "Send a follow-up to prospect@example.com from inbox inb_123.",
});
```

| Tool                | What it does                                            |
| ------------------- | ------------------------------------------------------- |
| `gork_create_inbox` | Provision an agent inbox                                |
| `gork_list_inboxes` | List inboxes on this key                                |
| `gork_send_email`   | Send (`inboxId`, `to`, `subject`, `text`, `inReplyTo?`) |
| `gork_read_emails`  | List / search (`inboxId?`, `q?`, `limit?`)              |
| `gork_get_message`  | Full body of one message (`messageId`)                  |
| `gork_create_draft` | Draft for human review                                  |
| `gork_send_draft`   | Dispatch a draft (`draftId`)                            |

<Warning>
  Agent-called sends execute immediately. For approval flows, expose only the draft tools (`gork_create_draft`, `gork_send_draft`) and let a human trigger the send.
</Warning>
