{"id":17670,"library":"graphlit-client","title":"Graphlit TypeScript Client SDK","description":"The Graphlit TypeScript Client SDK, currently at version 1.0.20260422004, provides the official programmatic interface for interacting with the Graphlit Platform. This SDK is designed to simplify the development of AI-powered applications by abstracting the complexities of knowledge retrieval and large language model (LLM) integration. It enables developers to ingest diverse content types, including PDFs, websites, audio, and video, and leverage advanced capabilities such as Retrieval-Augmented Generation (RAG) for conversational AI, automated insight extraction (summaries, entities, metadata), and the creation of knowledge graphs. The client library is actively maintained with frequent updates, as indicated by its rapid versioning and extensive 'What's New' sections covering features like OpenAI Responses API support, enhanced streaming provider resilience with automatic retries, and a comprehensive agent framework. Its key differentiators include built-in context management, artifact collection, and an autonomous agent harness, aiming to accelerate the development of sophisticated AI applications.","status":"active","version":"1.0.20260422004","language":"javascript","source_language":"en","source_url":"https://github.com/graphlit/graphlit-client-typescript","tags":["javascript","Graphlit","API","LLM","AI","RAG","OpenAI","PDF","parsing","typescript"],"install":[{"cmd":"npm install graphlit-client","lang":"bash","label":"npm"},{"cmd":"yarn add graphlit-client","lang":"bash","label":"yarn"},{"cmd":"pnpm add graphlit-client","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required runtime environment.","package":"node","optional":false}],"imports":[{"note":"The SDK is primarily designed for ES Modules. CommonJS `require` is generally not supported for direct imports.","wrong":"const GraphlitClient = require('graphlit-client').GraphlitClient;","symbol":"GraphlitClient","correct":"import { GraphlitClient } from 'graphlit-client';"},{"note":"Type imports are typically handled via `import { TypeName } from 'pkg'` when `esModuleInterop` and `allowSyntheticDefaultImports` are configured, or implicitly when using TypeScript.","wrong":"import type { StreamAgentOptions } from 'graphlit-client/types';","symbol":"StreamAgentOptions","correct":"import { StreamAgentOptions } from 'graphlit-client';"},{"note":"The `ProviderError` class is a top-level named export from the main package, consolidating error handling across providers.","wrong":"import { ProviderError } from 'graphlit-client/errors';","symbol":"ProviderError","correct":"import { ProviderError } from 'graphlit-client';"}],"quickstart":{"code":"import { GraphlitClient, StreamAgentOptions } from 'graphlit-client';\n\nasync function main() {\n  const apiKey = process.env.GRAPHLIT_API_KEY ?? '';\n  const secretKey = process.env.GRAPHLIT_SECRET_KEY ?? '';\n\n  if (!apiKey || !secretKey) {\n    console.error('Please set GRAPHLIT_API_KEY and GRAPHLIT_SECRET_KEY environment variables.');\n    process.exit(1);\n  }\n\n  const client = new GraphlitClient({\n    apiKey,\n    secretKey,\n    environment: 'prod' // Or 'dev', 'staging', etc.\n  });\n\n  const agentId = 'your-agent-id'; // Replace with a valid agent ID from your Graphlit platform\n  const prompt = 'Summarize the key findings from our latest quarterly report.';\n\n  console.log(`Running agent ${agentId} with prompt: \"${prompt}\"`);\n\n  const agentOptions: StreamAgentOptions = {\n    useResponsesApi: true, // Example option to route through OpenAI Responses API\n    debug: false,\n    conversationId: `user-session-${Date.now()}`,\n    // Additional options like model, maxTokens, temperature can be configured here.\n  };\n\n  try {\n    const stream = client.streamAgent(agentId, prompt, agentOptions);\n\n    for await (const chunk of stream) {\n      if (chunk.content) {\n        process.stdout.write(chunk.content);\n      }\n      // Additional handling for other chunk types (e.g., tool_calls, reasoning)\n    }\n    console.log('\\nAgent stream finished successfully.');\n  } catch (error) {\n    console.error('Error during agent streaming:', error);\n  }\n}\n\nmain().catch(console.error);","lang":"typescript","description":"This quickstart demonstrates how to initialize the GraphlitClient, configure API keys from environment variables, and execute a streaming agent with a specific prompt and options. It iterates over the streamed response chunks and prints the content."},"warnings":[{"fix":"Upgrade your Node.js runtime environment to version 20.0.0 or later. We recommend using an LTS version.","message":"Starting with v1.6.0, the Graphlit Client SDK requires Node.js version 20 or higher. Earlier Node.js versions are no longer supported and will cause runtime errors.","severity":"breaking","affected_versions":">=1.6.0"},{"fix":"Review your `StreamAgentOptions` and ensure your application logic accounts for automatic OpenAI Responses API routing. If specific temperature control is critical, set `reasoningEffort: 'none'` in your agent specification or disable `useResponsesApi` if available.","message":"The SDK automatically routes eligible OpenAI models (e.g., GPT-5.4) through the OpenAI Responses API for improved performance and intelligence. This can affect how certain parameters, like `temperature`, are handled (e.g., `temperature` is ignored if reasoning effort is not 'none'). Additionally, `tool_choice: \"required\"` is automatically sent on the first API request to ensure tool engagement, then reverts to `auto`.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update your error handling logic for streaming operations to exclusively rely on error events emitted from the stream. Leverage the new `ProviderError` class for typed access to error details like `provider`, `statusCode`, and `retryable`.","message":"Error event handling for streaming providers has been refined. Providers that previously emitted both an error event and threw an error will now only emit an error event, preventing duplicate error handling logic. A new `ProviderError` class normalizes error reporting.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"Upgrade your Node.js environment to version 20.0.0 or higher. You can use tools like `nvm` to manage multiple Node.js versions.","cause":"Attempting to use the SDK with an unsupported Node.js version (below 20.0.0).","error":"Error: The 'graphlit-client' package requires Node.js version >=20.0.0."},{"fix":"Verify that your `GRAPHLIT_API_KEY` and `GRAPHLIT_SECRET_KEY` environment variables are correctly set and contain valid credentials. Regenerate keys in the Graphlit platform if necessary.","cause":"The provided `apiKey` or `secretKey` during client initialization is incorrect, expired, or missing.","error":"Graphlit API Error: Unauthorized - Invalid API Key or Secret"},{"fix":"Ensure your project is configured for ES Modules (e.g., `\"type\": \"module\"` in `package.json`) and use `import { Symbol } from 'graphlit-client';`. If using CommonJS, ensure your setup correctly transpiles or targets CommonJS modules if the library is ESM-only.","cause":"Attempting to import the `graphlit-client` package using CommonJS `require()` syntax in an ES Module context, or vice-versa without proper transpilation.","error":"ReferenceError: require is not defined in ES module scope"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}