Skip to content

Add make add-model helper for interactive API key configuration#94

Merged
valITino merged 1 commit into
mainfrom
claude/keen-albattani-ipueuu
Jun 23, 2026
Merged

Add make add-model helper for interactive API key configuration#94
valITino merged 1 commit into
mainfrom
claude/keen-albattani-ipueuu

Conversation

@valITino

Copy link
Copy Markdown
Owner

Summary

Adds a new interactive helper script (scripts/add_model.sh) and corresponding make add-model target to simplify configuring API keys for containerized agent models (Claude Code, DeepSeek, Z.ai) without running the full setup wizard.

Key Changes

  • New script: scripts/add_model.sh

    • Interactive menu listing the three supported models with current key status
    • Prompts for the selected model's API key with hidden input (never echoed or logged)
    • Soft format validation for known providers (Anthropic, DeepSeek) with user override option
    • Per-model help text with links to obtain keys
    • Safely writes the key to .env using sed (no shell injection risk)
    • Creates .env from .env.example if missing, with secure permissions (chmod 600)
    • Mirrors color detection and helper patterns from setup.sh
  • Updated Makefile

    • Added .PHONY: add-model declaration
    • New add-model target that invokes the script
  • Updated README.md

    • Added new "Configuring a Model (API Keys)" section explaining the three ways to set keys:
      • Interactive: make add-model (recommended)
      • Manual: direct .env editing with reference table
    • Updated table of contents to link to the new section
    • Updated DeepSeek and Z.ai tutorial steps to mention make add-model as an option

Implementation Details

  • Secret handling: API keys are read via read -rsp (silent, no echo), passed only to set_env(), and never logged or printed
  • Safe .env mutation: Uses sed -i -E to remove any prior definition (commented or active) before appending, avoiding escaping pitfalls
  • Format validation: Checks Anthropic keys for sk-ant-* prefix and DeepSeek for sk-* prefix; unknown providers (Z.ai) always pass; user can override warnings
  • Terminal detection: Exits gracefully if not run interactively (e.g., piped input)
  • Color support: Respects NO_COLOR environment variable and TTY detection, matching project conventions

https://claude.ai/code/session_01Htst5VmusN6mUVN14vHyD4

Introduce an interactive helper to set or switch the API key for a
containerized agent (Claude Code, DeepSeek, or Z.ai / GLM 5.2) without
running the full setup wizard or hand-editing .env.

- scripts/add_model.sh: lists the models with their current key status,
  prompts for the chosen model's key (hidden input), and writes it to
  .env using the same injection-safe writer as setup.sh (the value is
  never passed through sed; the secret is never echoed or logged; .env is
  chmod 600). It also prints the matching launch command when done.
- Makefile: add the `add-model` target (plus its .PHONY entry).
- README: new "Configuring a Model (API Keys)" section, a TOC entry, a
  Makefile-shortcuts row, and pointers from the DeepSeek/Z.ai tutorials.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Htst5VmusN6mUVN14vHyD4
@valITino valITino merged commit a639313 into main Jun 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants