Create Memory langbase.memory.create()
Create a new AI memory on Langbase using the langbase.memory.create()
function.
Generate a User/Org API key
You will need to generate an API key to authenticate your requests. For more information, visit the User/Org API key documentation.
API reference
langbase.memory.create(options)
Function Signature
langbase.memory.create(options);
// with types.
langbase.memory.create(options: MemoryCreateOptions);
options
- Name
options
- Type
- MemoryCreateOptions
- Description
MemoryCreateOptions Object
interface MemoryCreateOptions { name: string; description?: string; embedding_model?: | 'openai:text-embedding-3-large' | 'cohere:embed-multilingual-v3.0' | 'cohere:embed-multilingual-light-v3.0' | 'google:text-embedding-004'; }
Following are the properties of the options object.
- Name
name
- Type
- string
- Required
- Required
- Description
Name of the memory.
- Name
description
- Type
- string
- Description
Description of the memory.
- Name
embedding_model
- Type
- string
- Description
The model to use for text embeddings. Available options:
openai:text-embedding-3-large
cohere:embed-multilingual-v3.0
cohere:embed-multilingual-light-v3.0
google:text-embedding-004
Default:
openai:text-embedding-3-large
Usage example
Install the SDK
npm i langbase
Environment variables
.env file
LANGBASE_API_KEY="<USER/ORG-API-KEY>"
Create memory
Create memory on Langbase
import {Langbase} from 'langbase';
const langbase = new Langbase({
apiKey: process.env.LANGBASE_API_KEY!,
});
const response = await langbase.memory.create({
name: 'knowledge-base',
description: 'An AI memory for storing company internal docs.',
});
Response
- Name
MemoryCreateResponse
- Type
- object
- Description
The response object returned by the
langbase.memory.create()
function.MemoryCreateResponse
interface MemoryCreateResponse { name: string; description: string; owner_login: string; url: string; embedding_model: | 'openai:text-embedding-3-large' | 'cohere:embed-multilingual-v3.0' | 'cohere:embed-multilingual-light-v3.0'; }
- Name
name
- Type
- string
- Description
Name of the memory.
- Name
description
- Type
- string
- Description
Description of the AI memory.
- Name
owner_login
- Type
- string
- Description
Login of the memory owner.
- Name
url
- Type
- string
- Description
Memory access URL.
- Name
embedding_model
- Type
- string
- Description
The embedding model used by the AI memory.
openai:text-embedding-3-large
cohere:embed-multilingual-v3.0
cohere:embed-multilingual-light-v3.0
Response of langbase.memory.create()
{
"name": "knowledge-base",
"description": "An AI memory for storing company internal docs.",
"owner_login": "user123",
"url": "https://langbase.com/user123/document-memory",
"embedding_model": "openai:text-embedding-3-large"
}