Alpha API

This API is currently in alpha. Breaking changes may occur between releases. We recommend pinning to a specific version and monitoring the changelog for updates.

TypeScript SDK Reference

The lightfast npm package provides a type-safe client for the Lightfast API.

Installation

bash
npm install lightfast

Client Configuration

typescript
import { Lightfast } from "lightfast";

const client = new Lightfast(config: LightfastConfig);

LightfastConfig

PropertyTypeRequiredDefaultDescription
apiKeystringYes-API key (starts with sk-lf-)
baseUrlstringNohttps://lightfast.aiAPI base URL
timeoutnumberNo30000Request timeout in milliseconds

Methods

Search through your organization's knowledge — decisions, observations, and documents.

typescript
const response = await client.search(input: SearchInput): Promise<SearchResponse>

SearchInput & Response

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

SearchFilters

PropertyTypeDescription
sourceTypesstring[]Source types to include (e.g., ["github", "linear"])
observationTypesstring[]Observation types to include (e.g., ["commit", "issue"])
sourcesstring[]Source identifiers to filter by
entityTypesstring[]Entity types to filter by
dateRange{ start?: string; end?: string }Date range filter with ISO datetime strings

Example

typescript
const results = await client.search({
  query: "authentication implementation",
  limit: 10,
  mode: "balanced",
  filters: {
    sourceTypes: ["github"],
    dateRange: {
      start: "2024-01-01T00:00:00Z",
      end: "2024-12-31T23:59:59Z",
    },
  },
});

console.log(results.data); // Array of search results
console.log(results.meta.total); // Total matching documents

proxySearch()

Discover connected providers, their resources, and available actions. Returns connection IDs, resource names with pre-computed action params, and the full action catalog.

typescript
const response = await client.proxySearch(): Promise<ProxySearchResponse>

Example

typescript
const { connections } = await client.proxySearch();

for (const conn of connections) {
  console.log(conn.provider);    // e.g., "github"
  console.log(conn.resources);   // Connected repos/projects with params
  console.log(conn.actions);     // Available actions
}

proxyCall()

Execute a provider API action. Use action strings from proxySearch() and pass a flat params object — resource params from the search response can be spread directly into the call. Auth is handled automatically.

typescript
const response = await client.proxyCall(input: ProxyCall): Promise<ProxyCallResponse>

ProxyCall

PropertyTypeRequiredDescription
actionstringYesAction to execute (e.g. github.list-pull-requests)
paramsRecord<string, unknown>NoAction parameters — spread resource params and add extras
connectionstringNoConnection ID (optional, for future multi-connection support)

Example

typescript
const result = await client.proxyCall({
  action: "github.list-pull-requests",
  params: { owner: "acme", repo: "web", state: "open" },
});

console.log(result.data);    // Raw provider API response
console.log(result.status);  // HTTP status code

Error Classes

The SDK exports typed error classes for handling specific error conditions.

typescript
import {
  AuthenticationError,
  ValidationError,
  NotFoundError,
  RateLimitError,
  NetworkError,
  ServerError,
} from "lightfast";
Error ClassHTTP StatusDescription
AuthenticationError401Invalid or expired API key
ValidationError400Invalid request parameters. Access error.details for field-specific errors
NotFoundError404Resource not found
RateLimitError429Too many requests. Access error.retryAfter for retry delay in seconds
ServerError500, 502, 503, 504Internal server error or service unavailable
NetworkError-Connection or timeout error

Type Exports

All request and response types are exported:

typescript
import type {
  LightfastConfig,
  SearchInput,
  SearchFilters,
  SearchRequest,
  SearchResponse,
  SearchResult,
  RerankMode,
  SearchContext,
  SearchLatency,
  ProxySearchResponse,
  ProxyConnection,
  ProxyAction,
  ProxyResource,
  ProxyCall,
  ProxyCallResponse,
} from "lightfast";