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

# Vercel AI SDK

> Wrap Darwin as typed server tools in a Vercel AI SDK application.

Create server-only tools that call the Darwin SDK or REST API. Keep the public Search schema separate from Act thread writes so the UI can render different confirmation behavior.

## Recommended application state

* selected Search `agent` and optional nested `capability`
* durable `threadId`, revision, and last consumed cursor
* stable `idempotencyKey` values for identical mutation retries
* current typed events and operation states

Stream explanatory model text separately from the authoritative thread state. A finished text stream does not mean external work completed.

## UI responsibilities

| Darwin response | UI treatment |
| - | - |
| Search results | Comparable selection cards in canonical order. |
| `awaiting_user` | A focused input request. |
| `connection_required` or `payment_required` | A user-triggered link to Darwin's first-party flow. |
| `approval_required` | Exact review terms with explicit approve and reject controls. |
| `completed` or `stopped` | A terminal result with no further polling. |

Keep the stream reconnectable and the thread state durable. A page refresh should call `get_thread` with the stored `threadId` and cursor, not create a new thread.


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