AI
Docs

Getting Started

Installation

Get up and running with the Investec AI SDK in under 5 minutes.

Requirements

  • Node.js 18+ or any edge runtime
  • Investec developer credentials (sandbox or production)
  • OpenAI API key

1. Install the package

npm install investec-ai

Or with pnpm / yarn:

pnpm add investec-ai
# or
yarn add investec-ai

2. Get your credentials

Log in to the Investec Developer Portal and create an app to get your Client ID, Client Secret, and API Key. The SDK defaults to the sandbox environment so you can develop safely.

.env.local
INVESTEC_CLIENT_ID=your_client_id
INVESTEC_CLIENT_SECRET=your_client_secret
INVESTEC_API_KEY=your_api_key
OPENAI_API_KEY=sk-...

3. Initialise the client

lib/sdk.ts
import { InvestecAI } from 'investec-ai';

export const sdk = new InvestecAI({
  clientId:     process.env.INVESTEC_CLIENT_ID!,
  clientSecret: process.env.INVESTEC_CLIENT_SECRET!,
  apiKey:       process.env.INVESTEC_API_KEY!,
  openaiApiKey: process.env.OPENAI_API_KEY!,
});
💡 Pass environment: 'production' to use live Investec data instead of sandbox.

4. Make your first API call

const accounts = await sdk.getAccounts();
console.log(accounts);
// [{ accountId: '...', accountName: 'Mr J Smith', productName: 'Private Bank Account', ... }]

const balance = await sdk.getBalance(accounts[0].accountId);
console.log(balance);
// { currentBalance: 12450.00, availableBalance: 11200.00, currency: 'ZAR' }

5. Add AI chat to your app

One function call wires up the full AI chat handler — tools, system prompt, and streaming included.

app/api/chat/route.ts
import { createChatHandler } from 'investec-ai';
import { sdk } from '@/lib/sdk';

export const POST = createChatHandler(sdk);

Then use the Vercel AI SDK's useChat hook on the frontend to connect to it.