@krishivpb60/krims-code-sdk
v0.1.0
Published
Starter SDK for Krims Code CLI and IDE integrations
Maintainers
Readme
Krims Code SDK
A lightweight, zero-dependency, universal developer SDK for integrating with the Krims Code ecosystem and querying a wide array of AI model providers.
Key Features
- Multi-Provider Support: Out-of-the-box wrappers for OpenAI, Google Gemini, Anthropic Claude, Cohere, Ollama (local), Groq, Together, Cerebras, Mistral, Fireworks, OpenRouter, DeepSeek, Perplexity, and xAI.
- Unified Chat Client: Perform stateless queries across different API providers with a single, simple
.ask(prompt)method. - Stateful Client-Side Sessions: Use
KrimsSessionto manage conversation histories locally. Chat histories are automatically mapped to the appropriate provider format. - Zero-Config Integrations: Auto-detects standard environment variables (like
OPENAI_API_KEY,GOOGLE_API_KEY, etc.). - TypeScript Support: Native
.d.tsdeclarations included for autocomplete and code validation. - Zero Dependencies: Lightweight and fast, using native
fetchand standard web APIs.
Installation
npm install krims-code-sdkQuick Start
1. Zero-Config (Using local Krims Chatbot Server)
By default, the SDK targets the local Krims Chatbot backend at http://localhost:3000.
import { createKrimsClient } from 'krims-code-sdk';
const client = createKrimsClient();
// Call local health check
const health = await client.health();
console.log('Status:', health);
// Call local Markov AI model
const res = await client.ask('Who created you?');
console.log('Response:', res.text);2. Multi-Provider Queries (e.g. Google Gemini)
Configuring a specific provider is simple. The SDK handles formatting differences underneath.
import { createKrimsClient } from 'krims-code-sdk';
// Auto-detects process.env.GOOGLE_API_KEY
const client = createKrimsClient({
provider: 'google', // or 'openai', 'anthropic', 'cohere', 'groq', etc.
model: 'gemini-2.5-flash'
});
const res = await client.ask('Explain quantum computing in one sentence.');
console.log('Gemini:', res.text);3. Stateful Chat Sessions
The stateful KrimsSession handles storing message history and appends it automatically to subsequent calls in the session.
import { createKrimsClient } from 'krims-code-sdk';
const client = createKrimsClient({
provider: 'openai',
apiKey: 'your-openai-api-key'
});
const session = client.createSession({
name: 'coding-assistant',
systemInstruction: 'You are a Senior JavaScript developer.'
});
// Turn 1
let res = await session.ask('What is closures?');
console.log(res.text);
// Turn 2 (Session maintains context of Turn 1 automatically)
res = await session.ask('Can you show me a code example?');
console.log(res.text);
// View cumulative history
console.log(session.getHistory());API Reference
KrimsClient Options
When calling createKrimsClient(options) or new KrimsClient(options), you can configure:
| Option | Type | Description | Environment Variable Fallback |
| :--- | :--- | :--- | :--- |
| provider | string | The AI provider to query (e.g. openai, google, anthropic, cohere, groq, together, krims, custom). | - |
| model | string | The model identifier. | Default values defined per provider |
| apiKey | string | API authorization key. | OPENAI_API_KEY, GOOGLE_API_KEY, ANTHROPIC_API_KEY, etc. |
| baseUrl | string | Custom root URL for the endpoints. | KRIMS_BASE_URL (for krims provider only) |
| headers | object | Custom headers to append on every request. | - |
| timeout | number | Timeout in milliseconds (default: 30000). | - |
| fetchFn | function | Custom fetch function (for proxies or custom clients). | globalThis.fetch |
Running Tests
To run the unit tests natively in Node:
npm test