0.0.8 • Published 12 months ago

@letta-ai/vercel-ai-sdk-provider v0.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

AI SDK - Letta Provider

NPM Version

Setup

The Letta provider is available in the @letta-ai/vercel-ai-sdk-provider module. You can install it with

npm i @letta-ai/vercel-ai-sdk-provider

Provider Instance

You can import the default provider instance letta from @letta-ai/vercel-ai-sdk-provider:

import { letta } from '@letta-ai/vercel-ai-sdk-provider';

Quick Start

Using Letta Cloud (https://api.letta.com)

Create a file called .env.local and add your API Key

LETTA_API_KEY=<your api key>
import { lettaCloud } from '@letta-ai/vercel-ai-sdk-provider';
import { generateText } from 'ai';

const { text } = await generateText({
  model: lettaCloud('your-agent-id'),
  prompt: 'Write a vegetarian lasagna recipe for 4 people.',
});

Local instances (http://localhost:8283)

import { lettaLocal } from '@letta-ai/vercel-ai-sdk-provider';
import { generateText } from 'ai';

const { text } = await generateText({
  model: lettaLocal('your-agent-id'),
  prompt: 'Write a vegetarian lasagna recipe for 4 people.',
});

Custom setups

import { createLetta } from '@letta-ai/vercel-ai-sdk-provider';
import { generateText } from 'ai';

const letta = createLetta({
    baseUrl: '<your-base-url>',
    token: '<your-access-token>'
})

const { text } = await generateText({
  model: letta('your-agent-id'),
  prompt: 'Write a vegetarian lasagna recipe for 4 people.',
});

Using other Letta Client Functions

The vercel-ai-sdk-provider extends the letta node client, you can access the operations directly by using lettaCloud.client or lettaLocal.client or your custom generated letta.client

import { lettaCloud } from '@letta-ai/vercel-ai-sdk-provider';

lettaCloud.agents.list();

More Examples

Check out our simple example using nextjs to stream letta messages to your frontend in examples/letta-ai-sdk-example

0.0.8

12 months ago

0.0.7

12 months ago

0.0.6

12 months ago

0.0.5

12 months ago

0.0.4

12 months ago

0.0.3

12 months ago

0.0.2

12 months ago

0.0.1

12 months ago