Memory: Create v1

The create memory API endpoint allows you to create a new memory on Langbase dynamically with API. This endpoint requires a User or Org API key.


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.


POST/v1/memory

Create a new memory

Create a new memory by sending the memory data inside the request body.

Headers

  • Name
    Content-Type
    Type
    string
    Required
    Required
    Description

    Request content type. Needs to be application/json.

  • Name
    Authorization
    Type
    string
    Required
    Required
    Description

    Replace <YOUR_API_KEY> with your user/org API key.

Body Parameters

  • Name
    name
    Type
    string
    Required
    Required
    Description

    Name of the memory.

  • Name
    description
    Type
    string
    Description

    Short description of the memory.

    Default: ''

Optional Parameters

  • Name
    embedding_model
    Type
    string
    Description

    Name of the embedding model to use for the memory.

    Default: openai:text-embedding-3-large

    Supported models:

    • openai:text-embedding-3-large
    • cohere:embed-multilingual-v3.0
    • cohere:embed-multilingual-light-v3.0
    • google:text-embedding-004
  • Name
    chunk_size
    Type
    number
    Description

    Maximum number of characters in a single chunk.

    Default: 1024

    Maximum: 30000

    Appropriate value

    Cohere has a limit of 512 tokens (1 token ~= 4 characters in English). If you are using Cohere models, adjust the chunk_size accordingly. For most use cases, default values should work fine.

  • Name
    chunk_overlap
    Type
    number
    Description

    Number of characters to overlap between chunks.

    Default: 256

    Maximum: Less than chunk_size

Create Memory

POST
/v1/memory
import {Langbase} from 'langbase';

const langbase = new Langbase({
  apiKey: '<YOUR_API_KEY>', // Replace with your API key
});

const response = await langbase.memory.create({
  name: 'multilingual-knowledge-base',
  description: 'Advanced memory with multilingual support',
  embedding_model: 'cohere:embed-multilingual-v3.0'
});

Response

  • Name
    Memory
    Type
    object
    Description

    The response object returned by the API endpoint.

    Memory

    interface Memory {
      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'
        | 'google:text-embedding-004';
    }
    
    • 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 studio 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
      • google:text-embedding-004

API Response

{
  "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"
}