Disclaimer: This SDK is not affiliated with or endorsed by any Large Language Model provider. The tekimax-sdk was created independently to support educational workshops and promote AI literacy. We are actively looking for partnerships and collaborations to make this SDK more robust for AI literacy initiatives.

The Tekimax SDK provides a comprehensive interface for interacting with Large Language Models. This document provides an overview of the main components and modules available in the SDK.

Educational Purpose

This SDK was developed specifically for educational workshops and AI literacy initiatives. The API is designed to be:

  • Beginner-friendly: Clear interfaces that help newcomers learn about LLM concepts
  • Workshop-oriented: Structured for classroom and workshop settings
  • Documentation-rich: Extensive explanations to support the learning process

SDK Architecture

The SDK is organized into several modules, each handling specific functionality:

OllamaClient
├── models (ModelManager)
├── embeddings (EmbeddingsManager)
├── fineTuning (FineTuningManager)
├── openai (OpenAICompatManager)
└── tools (ToolsManager)

Core Client

The main entry point for the SDK is the OllamaClient class. It provides access to all API functionality:

import { OllamaClient } from '@tekimax/ollama-sdk';

const client = new OllamaClient({
  baseUrl: 'http://localhost:11434', // Default
  apiKey: 'your-api-key' // Optional
});

Main Components

ModelManager

Handles operations related to LLM models, such as listing, pulling, and generating text:

// List available models
const models = await client.models.list();

// Pull a new model
await client.models.pull('llama2');

// Generate text
const response = await client.models.generate({
  model: 'llama2',
  prompt: 'Hello, world!'
});

EmbeddingsManager

Creates vector embeddings from text inputs:

const embedding = await client.embeddings.create({
  model: 'nomic-embed-text',
  prompt: 'Semantic text representation'
});

FineTuningManager

Manages model fine-tuning operations:

// Initialize fine-tuning for a model
await client.fineTuning.createJob({
  model: 'llama2',
  trainingFile: './training_data.jsonl'
});

// Check fine-tuning status
const status = await client.fineTuning.getStatus('job-123');

OpenAICompatManager

Provides an OpenAI-compatible interface for using Ollama models:

// Create an OpenAI-compatible client
const openai = client.openai.createClient({
  defaultModel: 'llama2'
});

// Use OpenAI-style API calls
const completion = await openai.chat.completions.create({
  messages: [
    { role: 'user', content: 'Hello!' }
  ],
  temperature: 0.7
});

ToolsManager

Enables function/tool calling capabilities with supported models:

// Define tools
const tools = [/* tool definitions */];

// Call model with tools
const response = await client.tools.callWithTools({
  model: 'llama3',
  prompt: 'What is the weather in Paris?',
  tools
});

Utility Classes

The SDK also includes several utility classes:

  • StreamParser: Handles streaming responses from the API
  • RequestBuilder: Constructs API requests with appropriate headers and parameters
  • ResponseHandler: Processes and validates API responses

Error Handling

All SDK methods use promise-based error handling. Errors from the API are wrapped in appropriate error classes:

try {
  await client.models.generate({
    model: 'non-existent-model',
    prompt: 'Hello!'
  });
} catch (error) {
  if (error.code === 'MODEL_NOT_FOUND') {
    console.error('The specified model was not found');
  } else {
    console.error('An error occurred:', error.message);
  }
}

TypeScript Support

The SDK is written in TypeScript and provides comprehensive type definitions for all API operations, making it easier to work with in TypeScript projects.

Next Steps

For detailed information on each component, see: