Get Thread langbase.threads.get()

You can use the threads.get() function to retrieve thread information and its metadata. This helps you access conversation history and thread details when needed.


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

Retrieve a thread by its ID.

Function Signature

langbase.threads.get(options);

// with types
langbase.threads.get(options: ThreadsGet);

options

  • Name
    options
    Type
    ThreadsGet
    Description

    ThreadsGet Object

    interface ThreadsGet {
    	threadId: string;
    }
    

Usage example

Install the SDK

npm i langbase

Environment variables

.env file

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

langbase.threads.get() example

Get Example

const thread = await langbase.threads.get({
	threadId: "thread_123"
});

Response

The response of the threads.get() function is a promise that resolves to a ThreadsBaseResponse object.

ThreadsBaseResponse

interface ThreadsBaseResponse {
	id: string;
	object: 'thread';
	created_at: number;
	metadata: Record<string, string>;
}

Response Example

{
	"id": "thread_123",
	"object": "thread",
	"created_at": 1709544000,
	"metadata": {
		"userId": "user123",
		"topic": "support",
		"status": "resolved"
	}
}