tekimax-ts 0.2.3 β 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -142
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,28 +1,52 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<img src="https://raw.githubusercontent.com/TEKIMAX/tekimax-ts/main/apps/docs/public/tekimax-logo.png" alt="Tekimax SDK Logo" width="
|
|
3
|
-
<h1>Tekimax
|
|
4
|
-
<p><strong>The Universal Standard
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
<img src="https://raw.githubusercontent.com/TEKIMAX/tekimax-ts/main/apps/docs/public/tekimax-logo.png" alt="Tekimax SDK Logo" width="120" />
|
|
3
|
+
<h1>Tekimax SDK</h1>
|
|
4
|
+
<p><strong>The Universal Standard</strong></p>
|
|
5
|
+
|
|
6
|
+
<p>
|
|
7
|
+
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License"></a>
|
|
8
|
+
<a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-5.0-3178C6.svg" alt="TypeScript"></a>
|
|
9
|
+
<a href="https://tekimax.com"><img src="https://img.shields.io/badge/Standard-Tekimax-000000.svg" alt="Standard"></a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/tekimax-ts"><img src="https://img.shields.io/npm/v/tekimax-ts.svg" alt="NPM Version"></a>
|
|
11
|
+
<a href="https://packagephobia.com/result?p=tekimax-ts"><img src="https://packagephobia.com/badge?p=tekimax-ts" alt="Bundle Size"></a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p>
|
|
15
|
+
Integrate <strong>OpenAI</strong>, <strong>Anthropic</strong>, <strong>Gemini</strong>, <strong>Ollama</strong>, <strong>Grok</strong>, and <strong>OpenRouter</strong> with a single, type-safe API.
|
|
16
|
+
</p>
|
|
9
17
|
|
|
18
|
+
<div>
|
|
19
|
+
<img src="https://img.shields.io/badge/OpenAI-412991?style=for-the-badge&logo=openai&logoColor=white" alt="OpenAI" />
|
|
20
|
+
<img src="https://img.shields.io/badge/Anthropic-D06940?style=for-the-badge&logo=anthropic&logoColor=white" alt="Anthropic" />
|
|
21
|
+
<img src="https://img.shields.io/badge/Gemini-8E75B2?style=for-the-badge&logo=google%20gemini&logoColor=white" alt="Gemini" />
|
|
22
|
+
<img src="https://img.shields.io/badge/Ollama-000000?style=for-the-badge&logo=ollama&logoColor=white" alt="Ollama" />
|
|
23
|
+
<img src="https://img.shields.io/badge/Grok-000000?style=for-the-badge&logo=x&logoColor=white" alt="Grok" />
|
|
24
|
+
<img src="https://img.shields.io/badge/OpenRouter-6366F1?style=for-the-badge&logo=openai&logoColor=white" alt="OpenRouter" />
|
|
25
|
+
</div>
|
|
10
26
|
</div>
|
|
11
27
|
|
|
12
|
-
|
|
28
|
+
---
|
|
13
29
|
|
|
14
|
-
|
|
15
|
-
npm install tekimax-ts
|
|
16
|
-
```
|
|
30
|
+
## π The Universal Standard
|
|
17
31
|
|
|
18
|
-
|
|
32
|
+
The **Tekimax SDK** solves the fragmentation of AI APIs. Instead of rewriting your integration code for every provider (handling different request formats, streaming implementations, and error types), you use **one standard interface**.
|
|
19
33
|
|
|
20
|
-
- **
|
|
21
|
-
- **
|
|
22
|
-
- **
|
|
23
|
-
- **
|
|
34
|
+
- **Write Once, Run Anywhere**: Switch between OpenAI (Cloud) and Ollama (Local) with a single line of config.
|
|
35
|
+
- **Type-Safe**: Full TypeScript support with Zod validation for inputs and outputs.
|
|
36
|
+
- **Multi-Modal**: Text, images, audio, video, and **embeddings** through a unified namespace API.
|
|
37
|
+
- **OpenResponses Catalog**: Fuses `models.dev` metadata into standard `ModelDefinition` objects for reasoning, modalities, and token limits.
|
|
38
|
+
- **Middleware Plugins**: Built-in architecture for Security (`PIIFilterPlugin`), Scalability (`MaxContextOverflowPlugin`), and Telemetry (`LoggerPlugin`).
|
|
39
|
+
- **React Ready**: Includes a `useChat` hook for instant UI integration, complete with SSE streaming.
|
|
24
40
|
- **Redis Adapter** _(optional)_: Response caching, rate limiting, token budgets, and session storage with any Redis client.
|
|
25
41
|
|
|
42
|
+
|
|
43
|
+
## π» Installation
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Install core and your desired adapters
|
|
47
|
+
npm install tekimax-ts
|
|
48
|
+
```
|
|
49
|
+
|
|
26
50
|
## π» Usage
|
|
27
51
|
|
|
28
52
|
### 1. Initialize the Client
|
|
@@ -52,60 +76,6 @@ const claude = new Tekimax({
|
|
|
52
76
|
const local = new Tekimax({
|
|
53
77
|
provider: new OllamaProvider({ baseUrl: 'http://localhost:11434' })
|
|
54
78
|
})
|
|
55
|
-
|
|
56
|
-
// Custom Model Proxies (e.g. Internal API gateways)
|
|
57
|
-
const proxyClient = new Tekimax({
|
|
58
|
-
provider: new OpenAIProvider({
|
|
59
|
-
apiKey: process.env.CUSTOM_PROXY_KEY,
|
|
60
|
-
baseURL: 'https://api.my-custom-proxy.internal/v1'
|
|
61
|
-
})
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
### Streaming
|
|
65
|
-
|
|
66
|
-
Tekimax-TS uses standard Javascript Async Iterables for real-time streaming:
|
|
67
|
-
|
|
68
|
-
```typescript
|
|
69
|
-
const stream = await client.text.generateStream({
|
|
70
|
-
model: "gpt-4o",
|
|
71
|
-
messages: [{ role: "user", content: "Tell me a story" }]
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
for await (const chunk of stream) {
|
|
75
|
-
process.stdout.write(chunk.delta)
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## π Plugin Architecture (Lifecycle Hooks)
|
|
80
|
-
|
|
81
|
-
The SDK provides a robust middleware architecture via `plugins`. You can snap in pre-built plugins for Security, Scalability, and Telemetry, or build your own.
|
|
82
|
-
|
|
83
|
-
```typescript
|
|
84
|
-
import { Tekimax, OpenAIProvider, PIIFilterPlugin, LoggerPlugin, MaxContextOverflowPlugin } from 'tekimax-ts'
|
|
85
|
-
|
|
86
|
-
const client = new Tekimax({
|
|
87
|
-
provider: new OpenAIProvider({ apiKey: 'sk-...' }),
|
|
88
|
-
plugins: [
|
|
89
|
-
new LoggerPlugin(), // Telemetry
|
|
90
|
-
new PIIFilterPlugin(), // Security: Redacts emails and SSNs
|
|
91
|
-
new MaxContextOverflowPlugin(15) // Scalability: Prevents context bloat in long loops
|
|
92
|
-
]
|
|
93
|
-
})
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### Building Custom Plugins
|
|
97
|
-
Implement the `TekimaxPlugin` interface to hook into the request/response lifecycle:
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
export interface TekimaxPlugin {
|
|
101
|
-
name: string
|
|
102
|
-
onInit?: (client: Tekimax) => void
|
|
103
|
-
beforeRequest?: (context: PluginContext) => Promise<void | PluginContext>
|
|
104
|
-
afterResponse?: (context: PluginContext, result: ChatResult) => Promise<void>
|
|
105
|
-
onStreamChunk?: (context: PluginContext, chunk: StreamChunk) => void
|
|
106
|
-
beforeToolExecute?: (toolName: string, args: unknown) => Promise<void>
|
|
107
|
-
afterToolExecute?: (toolName: string, result: unknown) => Promise<void>
|
|
108
|
-
}
|
|
109
79
|
```
|
|
110
80
|
|
|
111
81
|
### 2. Multi-Modal Interfaces
|
|
@@ -160,109 +130,95 @@ const analysis = await client.videos.analyze({
|
|
|
160
130
|
})
|
|
161
131
|
```
|
|
162
132
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
For full documentation, guides, and API references, visit **[docs.tekimax.com](https://docs.tekimax.com)**.
|
|
166
|
-
|
|
167
|
-
## π§ Motivation
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
Modern LLM systems have converged on similar primitives: messages, function calls, tool usage, and multimodal inputs but each provider encodes them differently. **Tekimax** standardizes these concepts, enabling:
|
|
171
|
-
|
|
172
|
-
- **One spec, many providers**: Describe inputs/outputs once; run on OpenAI, Anthropic, Gemini, or local models.
|
|
173
|
-
- **Composable agentic loops**: Unified streaming, tool invocation, and message orchestration.
|
|
174
|
-
- **Easier evaluation and routing**: Compare providers, route requests, and log results through a shared schema.
|
|
175
|
-
- **Blueprints for provider APIs**: Labs and model providers wanting to expose their APIs in a common format can easily do so.
|
|
176
|
-
|
|
177
|
-
## π Key Principles
|
|
178
|
-
|
|
179
|
-
### Agentic Loop
|
|
180
|
-
|
|
181
|
-
All models, to some extent, exhibit agency: the ability to perceive input, reason, act through tools, and reflect on outcomes.
|
|
133
|
+
#### Embeddings
|
|
182
134
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
Each item type has a defined schema that binds it and contains properties specific to its unique purpose.
|
|
135
|
+
```typescript
|
|
136
|
+
const vectors = await client.text.embed({
|
|
137
|
+
model: 'text-embedding-3-small',
|
|
138
|
+
input: ['Hello world', 'Tekimax SDK is awesome']
|
|
139
|
+
})
|
|
140
|
+
console.log(vectors.embeddings)
|
|
141
|
+
```
|
|
192
142
|
|
|
193
|
-
|
|
143
|
+
### 3. Cross-Provider Model Catalog
|
|
194
144
|
|
|
195
|
-
|
|
145
|
+
The SDK strictly implements the **OpenResponses** schema, optionally fusing metadata from `models.dev` so your application always knows what capabilities the active provider supports.
|
|
196
146
|
|
|
197
|
-
|
|
147
|
+
```typescript
|
|
148
|
+
// Returns standard ModelDefinition[] populated with reasoning levels, modal limits, and costs
|
|
149
|
+
const models = await client.provider.getModels?.()
|
|
198
150
|
|
|
199
|
-
|
|
151
|
+
if (models) {
|
|
152
|
+
console.log(models.find(m => m.id === 'gpt-4o')?.modalities.input) // ['text', 'image', 'audio', 'video']
|
|
153
|
+
}
|
|
154
|
+
```
|
|
200
155
|
|
|
201
|
-
|
|
156
|
+
## ποΈ Monorepo Structure
|
|
202
157
|
|
|
203
|
-
|
|
158
|
+
This repository is managed as a **Turborepo** monorepo.
|
|
204
159
|
|
|
205
|
-
|
|
160
|
+
- **`apps/docs`**: Documentation site (Next.js + Fumadocs).
|
|
161
|
+
- **`packages/*`**: Core SDK and Provider Adapters.
|
|
162
|
+
- **`tekimax-cli`**: Developer tools for Tekimax.
|
|
206
163
|
|
|
207
|
-
|
|
164
|
+
### Commands
|
|
208
165
|
|
|
209
|
-
|
|
166
|
+
```bash
|
|
167
|
+
# Build all packages
|
|
168
|
+
npx turbo build
|
|
210
169
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
- **Secured by Chainguard**: Our build pipeline and artifacts rely on [Chainguard Images](https://www.chainguard.dev/chainguard-images)βhardened, minimal container images designed to secure the software supply chain. Chainguard images are stripped of shells, package managers, and other unnecessary tools that attackers often exploit.
|
|
170
|
+
# Run tests
|
|
171
|
+
npx turbo test
|
|
214
172
|
|
|
215
|
-
|
|
173
|
+
# Start Docs Site
|
|
174
|
+
npx turbo dev --filter=docs
|
|
175
|
+
```
|
|
216
176
|
|
|
217
177
|
## β‘ Optional Redis Adapter
|
|
218
178
|
|
|
179
|
+
No extra dependency β bring your own `ioredis`, `@upstash/redis`, or `node-redis`:
|
|
180
|
+
|
|
219
181
|
```typescript
|
|
220
182
|
import { ResponseCache, RateLimiter, TokenBudget, SessionStore } from 'tekimax-ts'
|
|
221
183
|
import Redis from 'ioredis'
|
|
222
184
|
|
|
223
185
|
const redis = new Redis(process.env.REDIS_URL)
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const
|
|
227
|
-
|
|
186
|
+
|
|
187
|
+
// Cache AI responses (avoid repeat API costs)
|
|
188
|
+
const cache = new ResponseCache(redis, { ttl: 3600 })
|
|
189
|
+
|
|
190
|
+
// Enforce rate limits per provider
|
|
191
|
+
const limiter = new RateLimiter(redis, { maxRequests: 60, windowSeconds: 60 })
|
|
192
|
+
|
|
193
|
+
// Track daily token spend
|
|
194
|
+
const budget = new TokenBudget(redis, { maxTokens: 100_000, periodSeconds: 86400 })
|
|
195
|
+
|
|
196
|
+
// Conversation state for serverless
|
|
197
|
+
const sessions = new SessionStore(redis, { ttl: 1800 })
|
|
228
198
|
```
|
|
229
199
|
|
|
230
200
|
## πΊοΈ Roadmap
|
|
231
201
|
|
|
232
202
|
| Feature | Description | Status |
|
|
233
203
|
|---------|-------------|--------|
|
|
234
|
-
| **
|
|
235
|
-
| **
|
|
236
|
-
| **
|
|
237
|
-
| **
|
|
238
|
-
| **Observability** |
|
|
239
|
-
| **
|
|
204
|
+
| **Middleware Plugins** | Pre-built and custom lifecycle hooks for Security, Telemetry, and Scalability. | β
Shipped |
|
|
205
|
+
| **OpenResponses Catalog** | Provider abstraction parsing `models.dev` metadata for token limits, reasoning capabilities, and allowed modalities. | β
Shipped |
|
|
206
|
+
| **Real-time SSE Streaming** | Native SDK token streaming, `StreamChunk` event typing, and full React hooks support (`useChat`). | β
Shipped |
|
|
207
|
+
| **Redis Adapter** | Optional response caching, rate limiting, token budget tracking, and session storage with any Redis client. | β
Shipped |
|
|
208
|
+
| **Observability** | Telemetry and tracing via `plugins` architecture. | β
Shipped |
|
|
209
|
+
| **Batch API** | Queue thousands of requests and retrieve results asynchronously. | π Planned |
|
|
210
|
+
| **Edge Runtime** | Cloudflare Workers / Deno support. | π Planned |
|
|
211
|
+
| **Assistants / Threads** | Stateful conversation management with persistence. | π Planned |
|
|
212
|
+
| **Fine-tuning API** | Programmatic fine-tuning via internal and integrated APIs. | π Planned |
|
|
240
213
|
|
|
241
214
|
> **Want to help?** Pick a feature and open a PR, or join the discussion in [GitHub Issues](https://github.com/TEKIMAX/tekimax-ts/issues).
|
|
242
215
|
|
|
243
|
-
##
|
|
216
|
+
## π Support
|
|
244
217
|
|
|
245
|
-
|
|
246
|
-
- Participate in **GitHub Discussions**.
|
|
247
|
-
- See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup instructions.
|
|
218
|
+
Tekimax is open source. If you find it valuable, please consider [becoming a sponsor](https://github.com/sponsors/TEKIMAX) to support long-term maintenance.
|
|
248
219
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
We're looking for Tekimax Partners to join our mission! Partner with us to push the boundaries of Tekimax and build amazing things together.
|
|
252
|
-
|
|
253
|
-
[LET'S CHAT](mailto:info@tekimax.com?subject=Tekimax%20Partnership)
|
|
254
|
-
|
|
255
|
-
## Code of Conduct
|
|
256
|
-
|
|
257
|
-
## Please note that this project is released with a [Contributor Code of Conduct](./CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
|
|
220
|
+
---
|
|
258
221
|
|
|
259
222
|
<div align="center">
|
|
260
|
-
<p>
|
|
261
|
-
<strong>Secured by <a href="https://www.chainguard.dev">Chainguard</a></strong><br>
|
|
262
|
-
Zero-CVE Images for a Safe Supply Chain
|
|
263
|
-
</p>
|
|
264
|
-
<p>
|
|
265
|
-
Built on the <a href="https://openresponses.org">OpenResponses Standard</a> β’ Generated with <a href="https://kubb.dev">Kubb</a>
|
|
266
|
-
</p>
|
|
267
|
-
<sub>Built with β€οΈ by the Tekimax Team</sub>
|
|
223
|
+
<p>Built with β€οΈ by the Tekimax Team</p>
|
|
268
224
|
</div>
|