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_live_ or sk_test_) |
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
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
query | string | Yes | - | Natural language search query |
limit | number | No | 10 | Number of results to return |
offset | number | No | 0 | Pagination offset |
mode | "fast" | "balanced" | "quality" | No | "balanced" | Search mode |
includeContext | boolean | No | true | Include surrounding context |
includeHighlights | boolean | No | true | Include highlighted snippets |
filters | SearchFilters | No | - | Filter results |
SearchFilters
| Property | Type | Description |
|---|---|---|
sources | string[] | Filter by source (e.g., ["github"]) |
dateRange | string | Filter by date (e.g., "30d", "7d") |
V1SearchResponse
contents()
Fetch full content for documents by their IDs.
ContentsInput
| Property | Type | Required | Description |
|---|---|---|---|
ids | string[] | Yes | Array of document IDs to fetch |
V1ContentsResponse
findSimilar()
Find content semantically similar to a given document or URL.
FindSimilarInput
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
id | string | One of id or url | - | Document ID to find similar content for |
url | string | One of id or url | - | URL to find similar content for |
limit | number | No | 10 | Number of results |
threshold | number | No | 0.5 | Minimum similarity score (0-1) |
sameSourceOnly | boolean | No | false | Only return results from same source |
excludeIds | string[] | No | - | Document IDs to exclude |
V1FindSimilarResponse
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 |
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