Skip to main content

Advanced Configuration

This document covers advanced configuration options for the @tekimax/ollama-sdk.

SDK Configuration

When initializing the SDK, you can provide various configuration options:

Connection Options

Remote Ollama Servers

You can connect to a remote Ollama server by specifying the host:

Secure Connections

For HTTPS connections:

Custom Headers

Add authentication or other custom headers:

Generation Parameters

When generating text, you can fine-tune the output with these parameters:

Handling Errors and Retries

For advanced error handling with retries:

Streaming Optimizations

For handling large streaming responses efficiently:

CLI Configuration

The CLI tool can be configured with environment variables:
You can also create a configuration file in your home directory:

Advanced Use Cases

Running Models in a Docker Container

If using Ollama in Docker:

Node.js Worker Threads

For handling intensive operations in separate threads:

Performance Tuning

For optimal performance with the SDK:
  1. Connection Reuse - Create a single SDK instance and reuse it
  2. Batch Processing - For multiple operations, process in parallel with Promise.all
  3. Stream Processing - For large responses, use streaming to process incrementally
  4. Model Selection - Choose smaller models for faster response times
  5. Context Management - Reuse context tokens to avoid reprocessing previous conversation