dazllm


Namedazllm JSON
Version 0.4.0 PyPI version JSON
download
home_pagehttps://github.com/darrenoakey/dazllm
SummarySimple, unified interface for all major LLMs
upload_time2025-08-03 11:07:04
maintainerNone
docs_urlNone
authorDarren Oakey
requires_python>=3.8
licenseMIT
keywords llm ai openai anthropic claude gemini ollama chatgpt gpt-4
VCS
bugtrack_url
requirements keyring requests colorama pydantic jsonschema Pillow openai anthropic google-generativeai google-ai-generativelanguage
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![](banner.jpg)

# dazllm 🚀

**Simple, unified interface for all major LLMs**

Stop juggling different APIs and libraries. `dazllm` gives you a clean, consistent way to chat with any LLM - from GPT-4 and Claude to local Ollama or LM Studio models.

## Features

✨ **Unified API** - Same interface for OpenAI, Anthropic, Google, and local models (Ollama, LM Studio)
🔧 **Smart Model Selection** - Choose by name, type, or let it auto-select  
🔐 **Secure Configuration** - API keys stored safely in system keyring  
📝 **Structured Output** - Get Pydantic models directly from LLM responses  
🎨 **Image Generation** - Create images with DALL-E and more  
💻 **CLI & Python API** - Use from command line or import in your code  

## Quick Start

### Installation

```bash
pip install dazllm
```

### Setup

Configure your API keys using keyring:

```bash
keyring set dazllm openai_api_key YOUR_OPENAI_KEY
keyring set dazllm anthropic_api_key YOUR_ANTHROPIC_KEY
keyring set dazllm google_api_key YOUR_GOOGLE_KEY
keyring set dazllm ollama_url http://localhost:11434
keyring set dazllm lmstudio_url http://localhost:1234
```

Check everything is working:

```bash
dazllm --check
```

### Usage

#### Command Line

```bash
# Simple chat
dazllm chat "What's the capital of France?"

# Use specific model  
dazllm chat --model openai:gpt-4 "Explain quantum computing"

# Use model type (auto-selects best available)
dazllm chat --model-type paid_best "Write a poem"

# Use provider default
dazllm chat --model openai "Tell me about AI"

# Structured output
dazllm structured "List 3 colors" --schema '{"type":"array","items":{"type":"string"}}'

# Generate images
dazllm image "a red cat wearing a hat" cat.png

# From file
dazllm chat --file prompt.txt --output response.txt
```

#### Python API

```python
from dazllm import Llm, ModelType
from pydantic import BaseModel

# Instance-based usage
llm = Llm("openai:gpt-4")
response = llm.chat("Hello!")

# Static/module-level usage
response = Llm.chat("Hello!", model="anthropic:claude-3-5-sonnet-20241022")
response = Llm.chat("Hello!", model_type=ModelType.PAID_BEST)

# Structured output with Pydantic
class ColorList(BaseModel):
    colors: list[str]

result = Llm.chat_structured("List 3 colors", ColorList)
print(result.colors)  # ['red', 'green', 'blue']

# Image generation
Llm.image("a sunset over mountains", "sunset.png")

# Conversation history
conversation = [
    {"role": "user", "content": "Hello"},
    {"role": "assistant", "content": "Hi there!"},
    {"role": "user", "content": "What's your name?"}
]
response = Llm.chat(conversation, model="ollama:mistral-small")
```

## Model Types

Instead of remembering model names, use semantic types:

- `local_small` - ~1B parameter models (fast, basic)
- `local_medium` - ~7B parameter models (good balance)  
- `local_large` - ~14B parameter models (best local quality)
- `paid_cheap` - Cost-effective cloud models
- `paid_best` - Highest quality cloud models

## Model Format

All models use the format `provider:model`:

- **OpenAI**: `openai:gpt-4o`, `openai:gpt-4o-mini`, `openai:dall-e-3`
- **Anthropic**: `anthropic:claude-3-5-sonnet-20241022`, `anthropic:claude-3-haiku-20240307`
- **Google**: `google:gemini-pro`, `google:gemini-flash`
- **Ollama**: `ollama:mistral-small`, `ollama:llama3:8b`, `ollama:codellama:7b`
- **LM Studio**: `lm-studio:mistral`, `lm-studio:llama3`

You can also use just the provider name (e.g., `openai`) to use that provider's default model.

## Configuration

API keys are stored securely in your system keyring:

```bash
# Set API keys
keyring set dazllm openai_api_key YOUR_OPENAI_KEY
keyring set dazllm anthropic_api_key YOUR_ANTHROPIC_KEY
keyring set dazllm google_api_key YOUR_GOOGLE_KEY
keyring set dazllm ollama_url http://localhost:11434
keyring set dazllm lmstudio_url http://localhost:1234

# Set default model (optional)
keyring set dazllm default_model openai:gpt-4o

# Check what's configured
dazllm --check
```

## Examples

### Building a Chatbot

```python
from dazllm import Llm

def chatbot():
    llm = Llm.model_named("openai:gpt-4o")
    conversation = []
    
    while True:
        user_input = input("You: ")
        if user_input.lower() == 'quit':
            break
            
        conversation.append({"role": "user", "content": user_input})
        response = llm.chat(conversation)
        conversation.append({"role": "assistant", "content": response})
        
        print(f"AI: {response}")

chatbot()
```

### Data Extraction

```python
from dazllm import Llm
from pydantic import BaseModel

class Person(BaseModel):
    name: str
    age: int
    city: str

class People(BaseModel):
    people: list[Person]

text = "John Doe, age 30, lives in New York. Jane Smith, age 25, lives in LA."

result = Llm.chat_structured(
    f"Extract people info from: {text}",
    People,
    model="openai:gpt-4o-mini"
)

for person in result.people:
    print(f"{person.name} is {person.age} years old and lives in {person.city}")
```

### Image Generation Pipeline

```python
from dazllm import Llm

# Generate image description
description = Llm.chat(
    "Describe a serene mountain landscape in detail",
    model_type="paid_cheap"
)

# Generate the image
image_path = Llm.image(description, "mountain.png", width=1024, height=768)
print(f"Image saved to {image_path}")
```

## Requirements

- Python 3.8+
- API keys for desired providers (OpenAI, Anthropic, Google)
- Ollama or LM Studio installed for local models

## License

MIT License

## Contributing

Contributions welcome! Please see the GitHub repository for guidelines.

---

**dazllm** - Making LLMs accessible to everyone! 🚀

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/darrenoakey/dazllm",
    "name": "dazllm",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "llm, ai, openai, anthropic, claude, gemini, ollama, chatgpt, gpt-4",
    "author": "Darren Oakey",
    "author_email": "Darren Oakey <darren.oakey@insidemind.com.au>",
    "download_url": "https://files.pythonhosted.org/packages/cb/4c/d508c51335afa940ae7a875fc32cbaf805070bbe89a9f40676af35480316/dazllm-0.4.0.tar.gz",
    "platform": null,
    "description": "![](banner.jpg)\n\n# dazllm \ud83d\ude80\n\n**Simple, unified interface for all major LLMs**\n\nStop juggling different APIs and libraries. `dazllm` gives you a clean, consistent way to chat with any LLM - from GPT-4 and Claude to local Ollama or LM Studio models.\n\n## Features\n\n\u2728 **Unified API** - Same interface for OpenAI, Anthropic, Google, and local models (Ollama, LM Studio)\n\ud83d\udd27 **Smart Model Selection** - Choose by name, type, or let it auto-select  \n\ud83d\udd10 **Secure Configuration** - API keys stored safely in system keyring  \n\ud83d\udcdd **Structured Output** - Get Pydantic models directly from LLM responses  \n\ud83c\udfa8 **Image Generation** - Create images with DALL-E and more  \n\ud83d\udcbb **CLI & Python API** - Use from command line or import in your code  \n\n## Quick Start\n\n### Installation\n\n```bash\npip install dazllm\n```\n\n### Setup\n\nConfigure your API keys using keyring:\n\n```bash\nkeyring set dazllm openai_api_key YOUR_OPENAI_KEY\nkeyring set dazllm anthropic_api_key YOUR_ANTHROPIC_KEY\nkeyring set dazllm google_api_key YOUR_GOOGLE_KEY\nkeyring set dazllm ollama_url http://localhost:11434\nkeyring set dazllm lmstudio_url http://localhost:1234\n```\n\nCheck everything is working:\n\n```bash\ndazllm --check\n```\n\n### Usage\n\n#### Command Line\n\n```bash\n# Simple chat\ndazllm chat \"What's the capital of France?\"\n\n# Use specific model  \ndazllm chat --model openai:gpt-4 \"Explain quantum computing\"\n\n# Use model type (auto-selects best available)\ndazllm chat --model-type paid_best \"Write a poem\"\n\n# Use provider default\ndazllm chat --model openai \"Tell me about AI\"\n\n# Structured output\ndazllm structured \"List 3 colors\" --schema '{\"type\":\"array\",\"items\":{\"type\":\"string\"}}'\n\n# Generate images\ndazllm image \"a red cat wearing a hat\" cat.png\n\n# From file\ndazllm chat --file prompt.txt --output response.txt\n```\n\n#### Python API\n\n```python\nfrom dazllm import Llm, ModelType\nfrom pydantic import BaseModel\n\n# Instance-based usage\nllm = Llm(\"openai:gpt-4\")\nresponse = llm.chat(\"Hello!\")\n\n# Static/module-level usage\nresponse = Llm.chat(\"Hello!\", model=\"anthropic:claude-3-5-sonnet-20241022\")\nresponse = Llm.chat(\"Hello!\", model_type=ModelType.PAID_BEST)\n\n# Structured output with Pydantic\nclass ColorList(BaseModel):\n    colors: list[str]\n\nresult = Llm.chat_structured(\"List 3 colors\", ColorList)\nprint(result.colors)  # ['red', 'green', 'blue']\n\n# Image generation\nLlm.image(\"a sunset over mountains\", \"sunset.png\")\n\n# Conversation history\nconversation = [\n    {\"role\": \"user\", \"content\": \"Hello\"},\n    {\"role\": \"assistant\", \"content\": \"Hi there!\"},\n    {\"role\": \"user\", \"content\": \"What's your name?\"}\n]\nresponse = Llm.chat(conversation, model=\"ollama:mistral-small\")\n```\n\n## Model Types\n\nInstead of remembering model names, use semantic types:\n\n- `local_small` - ~1B parameter models (fast, basic)\n- `local_medium` - ~7B parameter models (good balance)  \n- `local_large` - ~14B parameter models (best local quality)\n- `paid_cheap` - Cost-effective cloud models\n- `paid_best` - Highest quality cloud models\n\n## Model Format\n\nAll models use the format `provider:model`:\n\n- **OpenAI**: `openai:gpt-4o`, `openai:gpt-4o-mini`, `openai:dall-e-3`\n- **Anthropic**: `anthropic:claude-3-5-sonnet-20241022`, `anthropic:claude-3-haiku-20240307`\n- **Google**: `google:gemini-pro`, `google:gemini-flash`\n- **Ollama**: `ollama:mistral-small`, `ollama:llama3:8b`, `ollama:codellama:7b`\n- **LM Studio**: `lm-studio:mistral`, `lm-studio:llama3`\n\nYou can also use just the provider name (e.g., `openai`) to use that provider's default model.\n\n## Configuration\n\nAPI keys are stored securely in your system keyring:\n\n```bash\n# Set API keys\nkeyring set dazllm openai_api_key YOUR_OPENAI_KEY\nkeyring set dazllm anthropic_api_key YOUR_ANTHROPIC_KEY\nkeyring set dazllm google_api_key YOUR_GOOGLE_KEY\nkeyring set dazllm ollama_url http://localhost:11434\nkeyring set dazllm lmstudio_url http://localhost:1234\n\n# Set default model (optional)\nkeyring set dazllm default_model openai:gpt-4o\n\n# Check what's configured\ndazllm --check\n```\n\n## Examples\n\n### Building a Chatbot\n\n```python\nfrom dazllm import Llm\n\ndef chatbot():\n    llm = Llm.model_named(\"openai:gpt-4o\")\n    conversation = []\n    \n    while True:\n        user_input = input(\"You: \")\n        if user_input.lower() == 'quit':\n            break\n            \n        conversation.append({\"role\": \"user\", \"content\": user_input})\n        response = llm.chat(conversation)\n        conversation.append({\"role\": \"assistant\", \"content\": response})\n        \n        print(f\"AI: {response}\")\n\nchatbot()\n```\n\n### Data Extraction\n\n```python\nfrom dazllm import Llm\nfrom pydantic import BaseModel\n\nclass Person(BaseModel):\n    name: str\n    age: int\n    city: str\n\nclass People(BaseModel):\n    people: list[Person]\n\ntext = \"John Doe, age 30, lives in New York. Jane Smith, age 25, lives in LA.\"\n\nresult = Llm.chat_structured(\n    f\"Extract people info from: {text}\",\n    People,\n    model=\"openai:gpt-4o-mini\"\n)\n\nfor person in result.people:\n    print(f\"{person.name} is {person.age} years old and lives in {person.city}\")\n```\n\n### Image Generation Pipeline\n\n```python\nfrom dazllm import Llm\n\n# Generate image description\ndescription = Llm.chat(\n    \"Describe a serene mountain landscape in detail\",\n    model_type=\"paid_cheap\"\n)\n\n# Generate the image\nimage_path = Llm.image(description, \"mountain.png\", width=1024, height=768)\nprint(f\"Image saved to {image_path}\")\n```\n\n## Requirements\n\n- Python 3.8+\n- API keys for desired providers (OpenAI, Anthropic, Google)\n- Ollama or LM Studio installed for local models\n\n## License\n\nMIT License\n\n## Contributing\n\nContributions welcome! Please see the GitHub repository for guidelines.\n\n---\n\n**dazllm** - Making LLMs accessible to everyone! \ud83d\ude80\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Simple, unified interface for all major LLMs",
    "version": "0.4.0",
    "project_urls": {
        "Bug Reports": "https://github.com/darrenoakey/dazllm/issues",
        "Documentation": "https://github.com/darrenoakey/dazllm#readme",
        "Homepage": "https://github.com/darrenoakey/dazllm",
        "Repository": "https://github.com/darrenoakey/dazllm.git"
    },
    "split_keywords": [
        "llm",
        " ai",
        " openai",
        " anthropic",
        " claude",
        " gemini",
        " ollama",
        " chatgpt",
        " gpt-4"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8f20f754282fbc88f48fdba56e86b5526fabf1f1e419d5b1364346e7ea67e6b5",
                "md5": "f74b81bcd4d25caa4cf316e825fdea97",
                "sha256": "0a33497f0178488a9bf952c73df679426eaf79fa3a98efdb105f690168074f2b"
            },
            "downloads": -1,
            "filename": "dazllm-0.4.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f74b81bcd4d25caa4cf316e825fdea97",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 30349,
            "upload_time": "2025-08-03T11:07:02",
            "upload_time_iso_8601": "2025-08-03T11:07:02.280018Z",
            "url": "https://files.pythonhosted.org/packages/8f/20/f754282fbc88f48fdba56e86b5526fabf1f1e419d5b1364346e7ea67e6b5/dazllm-0.4.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "cb4cd508c51335afa940ae7a875fc32cbaf805070bbe89a9f40676af35480316",
                "md5": "5d004aefa6cd36f5c28ac8430c3bb345",
                "sha256": "95b4246cedbd3b54ce257d5bfefc35bffeb94eae157fedea53da677fc9428dac"
            },
            "downloads": -1,
            "filename": "dazllm-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "5d004aefa6cd36f5c28ac8430c3bb345",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 523034,
            "upload_time": "2025-08-03T11:07:04",
            "upload_time_iso_8601": "2025-08-03T11:07:04.122533Z",
            "url": "https://files.pythonhosted.org/packages/cb/4c/d508c51335afa940ae7a875fc32cbaf805070bbe89a9f40676af35480316/dazllm-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-03 11:07:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "darrenoakey",
    "github_project": "dazllm",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "keyring",
            "specs": [
                [
                    ">=",
                    "24.0.0"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    ">=",
                    "2.25.0"
                ]
            ]
        },
        {
            "name": "colorama",
            "specs": [
                [
                    ">=",
                    "0.4.0"
                ]
            ]
        },
        {
            "name": "pydantic",
            "specs": [
                [
                    ">=",
                    "2.0.0"
                ]
            ]
        },
        {
            "name": "jsonschema",
            "specs": [
                [
                    ">=",
                    "4.0.0"
                ]
            ]
        },
        {
            "name": "Pillow",
            "specs": [
                [
                    ">=",
                    "9.0.0"
                ]
            ]
        },
        {
            "name": "openai",
            "specs": [
                [
                    ">=",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "anthropic",
            "specs": [
                [
                    ">=",
                    "0.3.0"
                ]
            ]
        },
        {
            "name": "google-generativeai",
            "specs": [
                [
                    ">=",
                    "0.3.0"
                ]
            ]
        },
        {
            "name": "google-ai-generativelanguage",
            "specs": []
        }
    ],
    "lcname": "dazllm"
}
        
Elapsed time: 1.12546s