TypeScript SDK Reference
The lightfast npm package provides a type-safe client for the Lightfast API.
Installation
Client Configuration
LightfastConfig
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
apiKey | string | Yes | - | API key (starts with sk-lf-) |
baseUrl | string | No | https://lightfast.ai | API base URL |
timeout | number | No | 30000 | Request timeout in milliseconds |
Methods
search()
Search through workspace memory for relevant documents and observations.
SearchInput & Response
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
SearchFilters
| Property | Type | Description |
|---|---|---|
sourceTypes | string[] | Source types to include (e.g., ["github", "linear"]) |
observationTypes | string[] | Observation types to include (e.g., ["commit", "issue"]) |
actorNames | string[] | Actor names to filter by (e.g., ["@sarah", "@mike"]) |
dateRange | { start?: string; end?: string } | Date range filter with ISO datetime strings |
Example
contents()
Fetch full content for documents by their IDs.
ContentsInput & Response
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
Example
findSimilar()
Find content semantically similar to a given document or URL.
FindSimilarInput & Response
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
Example
graph()
Traverse the relationship graph from a starting observation. Returns connected observations with relationship edges.
GraphInput & Response
Example
related()
Find observations directly connected to a given observation via relationships. Returns related events grouped by source system.
RelatedInput & Response
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
Example
Error Classes
The SDK exports typed error classes for handling specific error conditions.
| Error Class | HTTP Status | Description |
|---|---|---|
AuthenticationError | 401 | Invalid or expired API key |
ValidationError | 400 | Invalid request parameters. Access error.details for field-specific errors |
NotFoundError | 404 | Resource not found |
RateLimitError | 429 | Too many requests. Access error.retryAfter for retry delay in seconds |
ServerError | 500, 502, 503, 504 | Internal server error or service unavailable |
NetworkError | - | Connection or timeout error |
Type Exports
All request and response types are exported:
Related
- TypeScript SDK Tutorial - Getting started guide with examples
- POST /v1/search - REST API endpoint reference
- GitHub Repository - SDK source code