createLangGraphClient
Construct a LangGraph SDK Client that accepts both absolute URLs
(http://localhost:2024) and relative /api-style paths that get
proxied by middleware in production. The SDK itself rejects
relative URLs, so this helper rewrites them against
window.location.origin when running in the browser.
Single source of truth for the absolute-URL rewrite — the streaming
transport (fetch-stream.transport.ts) and the threads adapter
(LangGraphThreadsAdapter) both go through here.
clientOptions.maxRetries maps to the SDK's callerOptions.maxRetries,
which governs how many times a failed request (including the initial
stream connect) is retried with exponential backoff before the error
surfaces. Omitted → the SDK default (currently 4). Apps under test set
0 so a forced connection failure surfaces immediately instead of after
the full backoff window.
import { createLangGraphClient } from '@threadplane/langgraph';Declaration · overload 1
export declare function createLangGraphClient(apiUrl: string, clientOptions?: LangGraphClientOptions): Client;Parameters
apiUrl· requiredstringclientOptions· optionalLangGraphClientOptions
Returns
ClientExamples
const client = createLangGraphClient(environment.langGraphApiUrl);
const threads = await client.threads.search({ limit: 50 });