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

# createArrayFn

> Batch process lists of inputs with Nuabase from your server

`createArrayFn` is optimized for server-side batch operations. Initialize `Nua` with your API key, define the array function, then pass an array plus the primary key field to keep results aligned.

## Initialize Nua with your API key

```typescript theme={null}
import { Nua } from 'nuabase';
import { z } from 'zod';

const nua = new Nua({ apiKey: process.env.NUABASE_API_KEY });
```

## Batch processing

```typescript theme={null}
const LeadInfo = z.object({
  company: z.string(),
  website: z.string().url().optional()
});

const enrichLeads = nua.createArrayFn({
  prompt: "Extract company info from these leads.",
  output: { name: "info", schema: LeadInfo }
});

const leads = [
  { id: 1, note: "Looking for analytics" },
  { id: 2, note: "Interested in a demo" }
];

// Pass the array and the name of the primary key field ('id')
const results = await enrichLeads(leads, 'id');
```

## Row-level caching

Nuabase caches rows for array functions. Re-running a batch only processes the rows that changed, saving time and compute.
