Krims Code AI SDK — Native Python client for multi-provider AI routing and stateful sessions
Project description
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-sdk
Quick 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file krims_code_sdk-0.1.0.tar.gz.
File metadata
- Download URL: krims_code_sdk-0.1.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
726d98d849595b4de734004c10c5cac5b5df57f0b600ca951172deca8ee6f5ca
|
|
| MD5 |
ef19000aebfcb1e1f303ddbc390044d5
|
|
| BLAKE2b-256 |
541fd4eefc374a4fc38450b50e3723a4f89d29bbcefcebe643abdebfae980256
|
File details
Details for the file krims_code_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: krims_code_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7fefe2ef7c331d09f4894963475f2fbadb45003bdb5604c971d82a2af395efc7
|
|
| MD5 |
8cf8a559b96fb776d4a34af5f16885ef
|
|
| BLAKE2b-256 |
ce6d883dc2ccf526340cba0881df24dfed755de746fc02fcc6b2adcf30238d69
|