TypeScript SDK
Coming Soon
The official TypeScript SDK is currently in development. For now, use the REST API directly.
Planned Installation
npm install @inherent/sdk
# or
yarn add @inherent/sdk
Planned Usage
import { Inherent } from '@inherent/sdk';
const client = new Inherent({ apiKey: 'inh_live_...' });
// Ingest a document
const doc = await client.documents.create({
content: 'Your document content...',
metadata: { title: 'My Document' }
});
// Search
const results = await client.search({
query: 'How does authentication work?',
limit: 5
});
for (const chunk of results.chunks) {
console.log(`Score: ${chunk.score}`);
console.log(`Content: ${chunk.content}`);
}
Current Alternative
Use fetch directly:
interface InherentConfig {
apiKey: string;
baseUrl?: string;
}
interface SearchResult {
chunks: Array<{
id: string;
content: string;
score: number;
document_id: string;
metadata: Record<string, unknown>;
}>;
query_id: string;
}
class InherentClient {
private apiKey: string;
private baseUrl: string;
constructor(config: InherentConfig) {
this.apiKey = config.apiKey;
this.baseUrl = config.baseUrl || 'https://api.inherent.systems/v1';
}
private async request<T>(
method: string,
path: string,
body?: unknown
): Promise<T> {
const response = await fetch(`${this.baseUrl}${path}`, {
method,
headers: {
'Authorization': `Bearer ${this.apiKey}`,
'Content-Type': 'application/json',
},
body: body ? JSON.stringify(body) : undefined,
});
if (!response.ok) {
throw new Error(`API error: ${response.status}`);
}
return response.json();
}
async search(query: string, limit = 10): Promise<SearchResult> {
return this.request<SearchResult>('POST', '/search', { query, limit });
}
async createDocument(content: string, metadata?: Record<string, unknown>) {
return this.request('POST', '/documents', { content, metadata });
}
}
// Usage
const client = new InherentClient({ apiKey: 'inh_live_...' });
const results = await client.search('authentication');
Waitlist
Want early access to the SDK? Join the waitlist.