Configure API keys for the LLM providers you want to use:
# OpenAI (default provider)OPENAI_API_KEY=sk-...OPENAI_ORGANIZATION_ID=org-... # Optional# Anthropic (Claude)ANTHROPIC_API_KEY=sk-ant-...# Google GeminiGEMINI_API_KEY=...# Mistral AIMISTRAL_API_KEY=...# OpenRouter (access to multiple models)OPENROUTER_API_KEY=...# Together AITOGETHERAI_API_KEY=...# DeepSeekDEEPSEEK_API_KEY=...# GroqGROQ_API_KEY=...
You only need to configure API keys for the providers you plan to use. LLM Magic will throw an error if you try to use a provider without its API key configured.
# Default model for all operationsLLM_MAGIC_MODEL=openai/gpt-4o-mini# Model for cost-sensitive operationsLLM_MAGIC_CHEAP_MODEL=openai/gpt-4o-mini# Model specifically for data extractionLLM_MAGIC_EXTRACTION_MODEL=anthropic/claude-3-5-sonnet-20241022# Model for chat operationsLLM_MAGIC_CHAT_MODEL=google/gemini-2.0-flash-lite# Model for generating embeddingsLLM_MAGIC_EMBEDDINGS_MODEL=openai/text-embedding-3-small
# Number of concurrent extraction operations (default: 3)LLM_MAGIC_EXTRACTION_CONCURRENCY=3# Default maximum tokens per model (default: 10000)LLM_MAGIC_DEFAULT_MAX_TOKENS=10000
Configure where processed artifacts (PDFs, images, etc.) are stored:
# Base path for artifacts (default: storage/app/magic-artifacts)LLM_MAGIC_ARTIFACTS_BASE=/path/to/artifacts# Laravel disk for artifacts (default: artifacts)LLM_MAGIC_ARTIFACTS_DISK=artifacts# Prefix for artifact paths (default: empty)LLM_MAGIC_ARTIFACTS_PREFIX=llm-magic/
LLM Magic uses Python for some operations (like PDF processing):
# Python working directoryLLM_MAGIC_PYTHON_CWD=/path/to/python# Use UV for Python package management (default: true)LLM_MAGIC_PYTHON_USE_UV=true# Path to UV executable (default: /usr/bin/env uv)LLM_MAGIC_PYTHON_UV_PATH=/usr/local/bin/uv# Path to Python binary (default: auto-detected)LLM_MAGIC_PYTHON_BIN_PATH=/path/to/python
Get a list of all available models programmatically:
use Mateffy\Magic;// Get all registered models$models = Magic::models();// Get the default model name$defaultName = Magic::defaultModelName();// Get the default model label$defaultLabel = Magic::defaultModelLabel();// Get the default model instance$model = Magic::defaultModel();