Connect Next.js
The @recursiv/sdk is a zero-dependency TypeScript SDK that runs in Server Components, API routes, and Client Components. This guide gets a Next.js app from install to a streaming agent.
Install
Configure the key
No account yet? Sign up and mint a key at recursiv.io/account/api-keys.
Keep the key server side. Put it in .env.local:
The SDK reads RECURSIV_API_KEY automatically, so on the server you can just do new Recursiv(). You can also pass the key explicitly:
First authenticated call
Most resources hang off a project. Create one, then run a query. Project IDs are UUIDs, so always use the id the API returns. Project-scoped calls return a { data } envelope.
Run and stream an agent
Create an agent against any model, then stream its replies. In Node and the browser use chatStream(), which yields an async iterable of { delta } chunks.
Create the agent once (in setup, a script, or the dashboard):
The model field is model agnostic. Pass any supported model id.
Where to go next
- Quickstart for the full set of first calls
- Add AI Agents to Next.js for agent details
- Add Authentication to Next.js for user auth
- API Reference for the full REST surface
- Recursiv ships hundreds of data integrations (Slack, email, databases, and more) that agents can call as tools