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(options)

List all messages in a thread.

Function Signature

langbase.threads.messages.list(options);

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

options

  • Name
    options
    Type
    ThreadMessagesList
    Description

    ThreadMessagesList Object

    interface ThreadMessagesList {
    	threadId: string;
    }
    

Usage example

Install the SDK

npm i langbase

Environment variables

.env file

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

langbase.threads.messages.list() example

List Messages Example

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

Response

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

ThreadMessagesBaseResponse

export interface 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> | {};
}

Response Example

[
	{
		"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": {}
	}
]