Skip to main content

A lightweight client for interacting with LLMs served via Ollama

Project description

OllamaFreeAPI

PyPI Version Python Versions License GitHub Actions

A lightweight, zero-configuration Python client for interacting with LLMs served via Ollama across distributed servers.

Relationship with ollama-python

OllamaFreeAPI builds upon the official ollama-python library with these key enhancements:

  • Zero Configuration: No need to set up endpoints or API keys
  • Pre-configured Models: Access to ready-to-use models across distributed servers
  • Automatic Failover: Built-in load balancing across multiple Ollama instances
  • Simplified Interface: Higher-level abstractions for common use cases

ℹ️ Under the hood, OllamaFreeAPI uses the official ollama Python client to communicate with Ollama servers.

Features

  • 🚀 Instant Setup - Works out-of-the-box with no configuration
  • 🌐 Distributed Network - Automatic routing to available servers
  • 🔍 Model Discovery - Browse available models with list_families() and list_models()
  • Performance Optimized - Intelligent server selection based on latency
  • 🔄 Seamless Integration - Compatible with existing Ollama deployments

Installation

pip install ollamafreeapi

Quick Start

from ollamafreeapi import OllamaFreeAPI

# Connect to the distributed Ollama network
client = OllamaFreeAPI()

# Discover available models
print("Available families:", client.list_families())
print("Mistral models:", client.list_models(family='mistral'))

# Have a conversation
response = client.chat(
    model_name="llama3:latest",
    prompt="Explain the difference between Python and JavaScript",
    temperature=0.7
)
print(response)

# Stream a response
for chunk in client.stream_chat("mistral:latest", "Write a short story about AI:"):
    print(chunk, end='', flush=True)

Advanced Features

Server Information

# Get all servers hosting a model
servers = client.get_model_servers("llama2:13b")
for server in servers:
    print(f"Server: {server['url']}")
    print(f"Location: {server['location']['country']}")
    print(f"Performance: {server['performance']['tokens_per_second']} tokens/s")

Request Generation

# Generate the raw API request
request = client.generate_api_request(
    model_name="deepseek-r1:7b",
    prompt="Explain blockchain technology",
    temperature=0.8,
    top_p=0.95,
    num_predict=256
)

Model Parameters

All API calls support these optional parameters:

Parameter Type Default Description
temperature float 0.7 Controls randomness (lower = more deterministic)
top_p float 0.9 Probability threshold for nucleus sampling
num_predict int 128 Maximum number of tokens to generate
stop list[str] [] Sequences where the model will stop generating
repeat_penalty float 1.1 Penalty for repeated content

Frequently Asked Questions

Q: How is this different from ollama-python?
A: OllamaFreeAPI provides pre-configured access to a distributed network of Ollama servers with automatic failover, while ollama-python requires manual server configuration.

Q: Do I need to run my own Ollama server?
A: No! OllamaFreeAPI connects to our managed network of servers by default.

Q: Can I use this with my existing Ollama installation?
A: Yes, you can configure it to use your local Ollama instance if preferred.

License

Distributed under the MIT License. See LICENSE for more information.

Support

For support, feature requests, or to report issues, please open an issue.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ollamafreeapi-0.1.0.tar.gz (38.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ollamafreeapi-0.1.0-py3-none-any.whl (42.6 kB view details)

Uploaded Python 3

File details

Details for the file ollamafreeapi-0.1.0.tar.gz.

File metadata

  • Download URL: ollamafreeapi-0.1.0.tar.gz
  • Upload date:
  • Size: 38.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ollamafreeapi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 379058fd0d50630029f0383427bd2dae08c936146998f0809efb0d6b3189a7e4
MD5 167e848ab789f4f2e43aae11c4bca5fd
BLAKE2b-256 8b874d3dc8ce6e899072655499191ea0ffe367213add963f4c63c4573bde4cb0

See more details on using hashes here.

File details

Details for the file ollamafreeapi-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ollamafreeapi-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 42.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ollamafreeapi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bdc7349e38c76a2ec254ddebc7aac6c141dbee16204623352a354449591274ff
MD5 9cdf7d0b68593bd5525030c454a9fde8
BLAKE2b-256 e42be434dbb06a344a72afdc080135709679745d1ec46e384f1ea463f34bdfc1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page