Custom Model Injection
Relevant source files
The following files were used as context for generating this wiki page:
Custom Model Injection in ollacc is the process by which a user can bypass the automatically curated list of "Top 10" popular models and manually specify any model available in their Ollama Cloud catalog. This feature ensures that users are not restricted to the models scraped from the Ollama homepage and can use specific or niche models for their Claude Code sessions.
The system manages this through a combination of live catalog resolution, a CLI-based interactive menu, and persistent configuration management. Once a custom model is injected, the system offers to persist it as a default, effectively streamlining subsequent launches.
Sources: README.md:27-31, lib/menu.sh:30-41
Model Resolution and Discovery
Before a custom model can be selected, ollacc attempts to resolve a list of available models. It fetches the user's authorized catalog from the Ollama Cloud API and attempts to intersect it with popular models scraped from the web. If the desired model is not among the top results, the "Custom" injection path becomes the primary method for model selection.
Catalog Retrieval Logic
The resolution process follows a tiered fallback strategy to ensure the launcher remains functional even during network instability or scraping failures.
| Step | Method | Description |
|---|---|---|
| 1 | Authorized API Call | Fetches https://ollama.com/api/tags using the ANTHROPIC_AUTH_TOKEN. |
| 2 | Web Scraping | Scrapes https://ollama.com/search?c=cloud for popular model slugs. |
| 3 | Intersection | Filters scraped models against the authorized API response. |
| 4 | Fallback | If scraping fails, it uses the raw order from the authorized API. |
| 5 | Last-Resort | Uses a hardcoded list if all network calls fail. |
Sources: lib/catalog.sh:22-77
The following diagram illustrates the catalog resolution and discovery flow:
Sources: lib/catalog.sh:22-70
Interactive Injection via UI
The model menu provides a dedicated option for custom injection. When the user selects the final index in the menu (calculated as the number of available models plus one), the script switches from selection mode to manual input mode.
Menu Selection Process
The menu_choose function handles the logic for differentiating between a standard list selection and a custom injection.
menu_choose() {
local custom_index=$(( ${#MAPFILE[@]} + 1 ))
local choice
read -r -p "Enter choice (1-$custom_index): " choice
if [[ "$choice" =~ ^[0-9]+$ ]]; then
if [[ "$choice" -ge 1 && "$choice" -le "${#MAPFILE[@]}" ]]; then
MODEL="${MAPFILE[$((choice-1))]}"
elif [[ "$choice" -eq "$custom_index" ]]; then
echo ""
local custom_model
read -r -p "➡️ Enter custom model name: " custom_model
MODEL="${custom_model:-minimax-m3}"
# ... fallback logic ...
fi
}
Sources: lib/menu.sh:26-48
Configuration and Persistence
Once a custom model is injected, the system manages its lifecycle through the ~/.ollacc/config file. This allows the custom choice to survive session restarts.
Persistence Flow
- Validation: The script compares the selected
$MODELagainst the existingOLLAMA_CLAUDE_DEFAULT_MODEL. - User Consent: If different, the user is prompted to save the new model as the default.
- Escaping: The
bash_escapefunction ensures the custom model name (which might include special characters like colons or version numbers) is safely stored. - Writing: The
config_setfunction usesawkto replace or append the model definition in the configuration file.
The sequence of model persistence is shown below:
Sources: lib/menu.sh:53-72, lib/config.sh:45-73
Configuration Variables
Custom models are stored using the following key in the configuration file:
- Key:
OLLAMA_CLAUDE_DEFAULT_MODEL - Location:
~/.ollacc/config - Permissions:
chmod 600(Read/Write for owner only)
Sources: install.sh:60-68, README.md:113-117
Bypassing the Menu
Users can also inject a custom model directly via the CLI using the --model flag. This bypasses the interactive menu entirely for a single execution. If a user wishes to clear a previously injected custom default and return to the menu, they use the --model-clear flag.
| Flag | Action |
|---|---|
--model <name> | Temporarily injects the specified model for the current run. |
--model-clear | Removes the saved custom model from the configuration. |
Sources: README.md:92-95, lib/flags.sh:12-20
Conclusion
Custom Model Injection provides the flexibility required to use any model within the Ollama Cloud ecosystem with Claude Code. By integrating manual input into the standard selection menu and providing persistent storage for those choices, ollacc maintains a balance between ease of use for popular models and full control for power users.
Sources: README.md:126-128, lib/menu.sh:53-72