TypeScript SDK
The core TypeScript SDK wraps every AINative API — ZeroDB, ZeroMemory, Chat, Files, Tables, Events, and Agent Swarm.
npm install @ainative/sdk
Quick Start
import { AINative } from '@ainative/sdk';
const client = new AINative({ apiKey: 'your-api-key' });
// Chat completions
const response = await client.chat.completions.create({
model: 'meta-llama/llama-3.3-70b-instruct',
messages: [{ role: 'user', content: 'What is ZeroDB?' }],
});
console.log(response.choices[0].message.content);
// Vector search
await client.vectors.upsert({
projectId: 'my-project',
vectors: [{ id: 'doc-1', content: 'ZeroDB is a vector database', metadata: { source: 'docs' } }],
});
const results = await client.vectors.search({
projectId: 'my-project',
query: 'vector database',
limit: 5,
});
// Memory
await client.memory.remember({
content: 'User prefers dark mode',
entityId: 'user-123',
importance: 0.8,
});
const memories = await client.memory.recall({
query: 'user preferences',
entityId: 'user-123',
});
Modules
| Module | Methods | Description |
|---|---|---|
client.chat | completions.create() | Chat completions with streaming |
client.vectors | upsert(), search(), delete() | Vector storage and similarity search |
client.memory | remember(), recall(), forget(), reflect(), profile() | ZeroMemory operations |
client.graph | entity(), edge(), traverse(), graphrag() | Context graph and GraphRAG |
client.files | upload(), download(), list(), delete() | S3-compatible file storage |
client.tables | create(), insert(), query(), update(), delete() | NoSQL tables |
client.events | publish(), subscribe() | Event streaming |
client.agents | register(), discover(), deploy() | Agent Cloud management |
client.swarm | create(), assign(), status() | Agent swarm orchestration |
Streaming
const stream = await client.chat.completions.create({
model: 'meta-llama/llama-3.3-70b-instruct',
messages: [{ role: 'user', content: 'Write a poem' }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
Error Handling
import { AINative, APIError, RateLimitError, AuthenticationError } from '@ainative/sdk';
try {
await client.chat.completions.create({ ... });
} catch (error) {
if (error instanceof RateLimitError) {
console.log(`Rate limited. Retry after ${error.retryAfter}s`);
} else if (error instanceof AuthenticationError) {
console.log('Invalid API key');
} else if (error instanceof APIError) {
console.log(`API error: ${error.status} ${error.message}`);
}
}
Configuration
const client = new AINative({
apiKey: 'your-api-key',
baseUrl: 'https://api.ainative.studio', // default
timeout: 30000, // ms, default 30s
maxRetries: 3, // default 3
});
Next Steps
- Agent SDK — Specialized SDK for Agent Cloud APIs
- Agent Runtime — Embeddable agent execution engine
- React SDK — React hooks and components