Skip to main content

AI agent for image generation with multi-provider LLM support and interactive CLI

Project description

MediaAgent

PyPI version Python License Build Downloads

AI-powered image generation with natural language. Features an interactive CLI with multiple LLM providers and image backends.

Quick Start

# Install
pip install -e .

# Start the CLI
media-agent

Setup

1. Install

python -m venv .venv
source .venv/bin/activate

# Basic install
pip install -e .

# With cloud LLM providers (recommended)
pip install -e ".[all-llm]"

2. Configure an LLM Provider

Choose one:

OpenAI (easiest)

/settings openai.api_key sk-your-key-here
/llm openai

Anthropic

/settings anthropic.api_key sk-ant-your-key-here
/llm anthropic

Ollama (free, local)

# Install Ollama first: https://ollama.ai
ollama pull llama3.2
ollama serve
/llm ollama llama3.2

Local HuggingFace (requires GPU)

media-agent download llm
/llm huggingface

3. Configure Image Generation

Local GPU (default, requires CUDA GPU)

media-agent download image
/image local

Nanobanana Cloud (no GPU needed)

/settings nanobanana.api_key your-key-here
/image nanobanana

4. Generate Images

Just chat naturally:

> Generate a sunset over mountains
> Create a cyberpunk city at night
> A cat wearing a tiny hat

Or use the direct command:

/generate a beautiful forest landscape

CLI Commands

Command Description
/help Show all commands
/generate <prompt> Generate an image
/llm <provider> Switch LLM (openai, anthropic, ollama, huggingface)
/image <provider> Switch image backend (local, nanobanana)
/settings <key> <value> Configure settings
/resolutions Show available image sizes
/unload Free GPU memory
/clear Clear chat history
/quit Exit

Command Line Usage

# Interactive mode
media-agent

# Generate directly
media-agent generate "a sunset over mountains"

# With options
media-agent generate "a cat" -r 1024x1024 -s 42

# Download models
media-agent download all

# Manage settings
media-agent settings list
media-agent settings openai.api_key sk-xxx

Python API

from media_agent import MediaAgent

# Using configured settings
agent = MediaAgent()
result = agent.run("Generate a sunset over mountains")
print(result)

# Specify providers
agent = MediaAgent(
    llm_provider="openai",
    llm_model="gpt-4o",
    image_provider="local",
)

# Direct generation (skip LLM)
path = agent.generate(
    prompt="A serene Japanese garden",
    resolution="1344x768",
    seed=42,
)

# Cleanup
agent.unload()

Image Resolutions

Name Size Best For
1024x1024 Square Balanced compositions
1344x768 16:9 Landscapes, wide scenes
768x1344 9:16 Portraits, tall subjects
1152x896 4:3 Slight landscape
896x1152 3:4 Slight portrait

Settings Location

Settings are stored in ~/.config/media_agent/settings.json. No environment variables needed.

Requirements

  • Python >= 3.10
  • For local image generation: CUDA GPU with 8GB+ VRAM
  • For cloud providers: API key only

License

MIT

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

media_agent-0.3.1.tar.gz (50.0 kB view details)

Uploaded Source

Built Distribution

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

media_agent-0.3.1-py3-none-any.whl (57.3 kB view details)

Uploaded Python 3

File details

Details for the file media_agent-0.3.1.tar.gz.

File metadata

  • Download URL: media_agent-0.3.1.tar.gz
  • Upload date:
  • Size: 50.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for media_agent-0.3.1.tar.gz
Algorithm Hash digest
SHA256 e168f7c995c95195cd7ef123b4a07ecc0c3aff0f16c781e884efc7320ae1c279
MD5 76e570820b0da2ac55ee250681c3db6d
BLAKE2b-256 2f95d5a21c3c7aa40770e3dbec410838bdbceca357e1497441123c7eb3b48bc2

See more details on using hashes here.

Provenance

The following attestation bundles were made for media_agent-0.3.1.tar.gz:

Publisher: publish.yml on slahiri/media-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file media_agent-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: media_agent-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 57.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for media_agent-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9264e381ba6ba3568470742c7c64c6fac6b09a4077770baab3dbc281d90a254c
MD5 485a49aa622c4b0f815482753ec47cca
BLAKE2b-256 4c255d160623bc78e0c3c7a19ddf689e46c4f79abbc6759d7f2a62533b01914f

See more details on using hashes here.

Provenance

The following attestation bundles were made for media_agent-0.3.1-py3-none-any.whl:

Publisher: publish.yml on slahiri/media-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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