Skip to content

TypeScript SDK

The TypeScript SDK is currently in development. For now, you can interact with DuraGraph using the REST API or the LangGraph SDK.

DuraGraph is compatible with the LangGraph TypeScript SDK:

import { Client } from '@langchain/langgraph-sdk';
// Point to your DuraGraph instance
const client = new Client({
apiUrl: 'http://localhost:8081',
});
// Create an assistant
const assistant = await client.assistants.create({
graphId: 'my-graph',
config: {},
});
// Create a thread
const thread = await client.threads.create();
// Run a workflow
const run = await client.runs.create(thread.thread_id, assistant.assistant_id, {
input: { message: 'Hello!' },
});
console.log('Run created:', run);
const baseUrl = 'http://localhost:8081/api/v1';
// Create an assistant
const response = await fetch(`${baseUrl}/assistants`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name: 'my-assistant',
graph_schema: {},
}),
});
const assistant = await response.json();
console.log('Created assistant:', assistant);
const runId = 'your-run-id';
const eventSource = new EventSource(`http://localhost:8081/api/v1/stream?run_id=${runId}`);
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Event:', data);
};
eventSource.onerror = () => {
eventSource.close();
};