TypeScript SDK for CognipeerAI Gateway - Multi-tenant AI services platform
npm install @cognipeer/cgate-sdkOfficial TypeScript/JavaScript SDK for CognipeerAI Gateway - A multi-tenant SaaS platform for AI and Agentic services.



- 🤖 Chat Completions - OpenAI-compatible chat API with streaming support
- 📊 Embeddings - Text vectorization for semantic search
- 🗄️ Vector Operations - Manage vector databases (Pinecone, Chroma, Qdrant, etc.)
- 📁 File Management - Upload and manage files with markdown conversion
- 🔍 Agent Tracing - Observability for agent executions
- 🔒 Type-Safe - Full TypeScript support with comprehensive types
- ⚡ Modern - ESM and CommonJS support, works in Node.js and browsers
``bash`
npm install @cognipeer/cgate-sdk
`bash`
yarn add @cognipeer/cgate-sdk
`bash`
pnpm add @cognipeer/cgate-sdk
`typescript
import { CGateClient } from '@cognipeer/cgate-sdk';
// Initialize the client
const client = new CGateClient({
apiKey: 'your-api-key',
baseURL: 'https://api.cognipeer.com', // Optional, defaults to production
});
// Chat completion
const response = await client.chat.completions.create({
model: 'gpt-4',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Hello!' },
],
});
console.log(response.choices[0].message.content);
// Streaming chat
const stream = await client.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Tell me a story' }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
// Create embeddings
const embeddings = await client.embeddings.create({
model: 'text-embedding-3-small',
input: 'Hello, world!',
});
console.log(embeddings.data[0].embedding);
// Vector operations
await client.vectors.upsert('my-provider', 'my-index', {
vectors: [
{
id: 'vec1',
values: [0.1, 0.2, 0.3],
metadata: { text: 'Hello world' },
},
],
});
const results = await client.vectors.query('my-provider', 'my-index', {
query: {
vector: [0.1, 0.2, 0.3],
topK: 5,
},
});
// File upload
const file = await client.files.upload('my-bucket', {
fileName: 'document.pdf',
data: 'data:application/pdf;base64,JVBERi0xLjQK...',
convertToMarkdown: true,
});
`
Full documentation is available at cognipeer.github.io/cgate-sdk
- Getting Started
- Chat API
- Embeddings API
- Vector API
- Files API
- Tracing API
- Examples
`typescript`
const client = new CGateClient({
apiKey: string; // Required: Your API token
baseURL?: string; // Optional: API base URL (default: https://api.cognipeer.com)
timeout?: number; // Optional: Request timeout in ms (default: 60000)
maxRetries?: number; // Optional: Max retry attempts (default: 3)
fetch?: typeof fetch; // Optional: Custom fetch implementation
});
#### Chat
- client.chat.completions.create(params) - Create chat completion (streaming supported)
#### Embeddings
- client.embeddings.create(params) - Create embeddings
#### Vectors
- client.vectors.providers.list(query?) - List vector providersclient.vectors.providers.create(data)
- - Create vector providerclient.vectors.indexes.list(providerKey)
- - List indexesclient.vectors.indexes.create(providerKey, data)
- - Create indexclient.vectors.indexes.get(providerKey, indexId)
- - Get index detailsclient.vectors.indexes.update(providerKey, indexId, data)
- - Update indexclient.vectors.indexes.delete(providerKey, indexId)
- - Delete indexclient.vectors.upsert(providerKey, indexId, data)
- - Upsert vectorsclient.vectors.query(providerKey, indexId, query)
- - Query vectorsclient.vectors.delete(providerKey, indexId, ids)
- - Delete vectors
#### Files
- client.files.buckets.list() - List bucketsclient.files.buckets.get(bucketKey)
- - Get bucket detailsclient.files.list(bucketKey, query?)
- - List filesclient.files.upload(bucketKey, data)
- - Upload file
#### Tracing
- client.tracing.ingest(data)` - Ingest tracing session
Check out the examples directory for more detailed usage:
- Chat with streaming
- RAG with vectors
- File processing
- Agent tracing
We welcome contributions! Please see our Contributing Guide for details.
MIT © CognipeerAI
- 📧 Email: support@cognipeer.com
- 📖 Documentation: cognipeer.github.io/cgate-sdk
- 🐛 Issues: GitHub Issues