🧠 AI Cortex#

The unified Python toolkit for accessing any LLM through Ollama β€” zero API keys, zero signup, completely free.

PyPI Version Downloads Python License: LGPL v3

What is AI Cortex?#

AI Cortex gives you a single, clean Python interface to hundreds of language models β€” Llama, Mistral, Gemma, DeepSeek, Qwen, and more β€” all served through Ollama. No accounts. No credit cards. No rate limits.

Whether you’re building a chatbot, a code assistant, a research tool, or an AI-powered app, AI Cortex handles the model discovery, server routing, and API compatibility so you don’t have to.

from aicortex import chat

# That's it. One line of Python, any model, any server.
response = chat("Explain neural networks like I'm five.")
print(response)

✨ Why AI Cortex?#

Feature

What it means for you

πŸ†“ 100% Free

No API keys, no billing, no subscriptions β€” ever

πŸ€– Any Model

Llama, Mistral, Gemma, DeepSeek, Qwen, and more

🌐 Any Server

Local Ollama, remote servers, or community endpoints

⚑ Streaming

Real-time token streaming for responsive UIs

πŸ”Œ OpenAI-Compatible

Drop-in replacement for openai client apps

πŸ›‘οΈ Type-Safe

Full type hints, stubs, and IDE autocomplete

πŸ”§ Production Ready

Automatic failover, multi-server routing, error handling

πŸ“¦ Lightweight

One dependency (ollama) for the core package

πŸš€ Get Started in 60 Seconds#

pip install aicortex-core
from aicortex import chat, models, families

# Chat with any model
print(chat("What is the speed of light?"))

# Discover what's available
print(families())   # ['llama', 'mistral', 'gemma', 'deepseek', 'qwen']
print(models("mistral"))  # ['mistral:7b', 'mistral:instruct', ...]

β†’ Full Quick Start Guide

πŸ“š Documentation#

Getting Started#

  • Installation β€” install options, requirements, and verification

  • Quick Start β€” your first chat in 5 minutes

  • Basic Usage β€” parameters, patterns, and error handling

Core Reference#

Deployment#

  • Server Mode β€” OpenAI-compatible REST API server

  • Tools β€” endpoint validation, model fetch/resolve/apply pipeline

Contributing#

πŸ—οΈ Architecture at a Glance#

aicortex/
β”œβ”€β”€ chat()          ← Your main entry point
β”œβ”€β”€ api.py          ← Ollama client, model registry, server routing
β”œβ”€β”€ chat.py         ← Stream / StreamEvent types
β”œβ”€β”€ models/         ← Bundled model metadata (JSON per family)
└── tools/
    β”œβ”€β”€ check_models.py    ← Validate live Ollama endpoints
    β”œβ”€β”€ fetch_models.py    ← Pull model lists from valid endpoints
    β”œβ”€β”€ resolve_models.py  ← Merge fetched data with IP metadata
    β”œβ”€β”€ apply_valid_models.py  ← Write resolved models into family JSONs
    └── server.py          ← OpenAI-compatible FastAPI proxy

πŸ“„ License#

AI Cortex is released under the GNU Lesser General Public License v3.0. You can use it freely in open-source and commercial projects.