List Messages langbase.threads.messages.list()

You can use the threads.messages.list() function to retrieve all messages in a thread. This helps you access the complete conversation history of a specific thread.


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.threads.messages.list()

Function Signature

langbase.threads.messages.list(options); // with types langbase.threads.messages.list(options: ThreadsCreate);

options

  • Name
    options
    Type
    ThreadMessagesList
    Description

    ThreadMessagesList Object

    threadId: string;
  • Name
    threadId
    Type
    string
    Required
    Required
    Description

    The ID of the thread.

Usage example

Install the SDK

npm i langbase

Environment variables

Environment variables

LANGBASE_API_KEY="<USER/ORG-API-KEY>"

List messages in a thread

List messages in a thread on Langbase

const messages = await langbase.threads.messages.list({ threadId: "thread_123" });

Response

  • Name
    ThreadMessagesBaseResponse
    Type
    array
    Description

    The response of the threads.messages.list() function is a promise that resolves to an array of ThreadMessagesBaseResponse objects.

    ThreadMessagesBaseResponse

    id: string; created_at: number; thread_id: string; content: string; role: Role; tool_call_id: string | null; tool_calls: ToolCall[] | []; name: string | null; attachments: any[] | []; metadata: Record<string, string> | {};

ThreadMessagesBaseResponse type of langbase.threads.messages.list()

[ { "id": "msg_125", "thread_id": "thread_123", "created_at": 1709544120, "role": "assistant", "content": "How can I help you today?", "tool_call_id": null, "tool_calls": [], "name": null, "attachments": [], "metadata": {} } ]