Skip to content

Support env-based API key, base_url, and model defaults for all LLM providers#21

Open
XOTaichi wants to merge 2 commits intoResearAI:mainfrom
XOTaichi:feat/openrouter-env-defaults
Open

Support env-based API key, base_url, and model defaults for all LLM providers#21
XOTaichi wants to merge 2 commits intoResearAI:mainfrom
XOTaichi:feat/openrouter-env-defaults

Conversation

@XOTaichi
Copy link
Copy Markdown

Summary

This PR adds .env-based defaults for all supported LLM providers so the CLI can fall back to provider-specific configuration when explicit flags are not passed.

What Changed

  • autofigure2.py

    • extended PROVIDER_CONFIGS so openrouter, bianxie, and gemini can read default API_KEY, BASE_URL, IMAGE_MODEL, and SVG_MODEL values from environment variables
    • updated method_to_svg() to fall back to provider-specific env defaults when --api_key, --base_url, --image_model, or --svg_model are omitted
    • preserved existing behavior where explicit CLI arguments still take precedence
  • .env.example

    • added documented example entries for:
      • OPENROUTER_API_KEY
      • OPENROUTER_BASE_URL
      • OPENROUTER_IMAGE_MODEL
      • OPENROUTER_SVG_MODEL
      • BIANXIE_API_KEY
      • BIANXIE_BASE_URL
      • BIANXIE_IMAGE_MODEL
      • BIANXIE_SVG_MODEL
      • GEMINI_API_KEY
      • GEMINI_BASE_URL
      • GEMINI_IMAGE_MODEL
      • GEMINI_SVG_MODEL
  • docker-compose.yml

    • passed the provider-specific env vars through to the container so the same .env defaults work in Docker deployments
  • README.md

    • documented the new provider env defaults in the English setup section
  • README_ZH.md

    • documented the new provider env defaults in the Chinese setup section

Why

Previously, only hardcoded provider defaults were available in code, and custom provider config had to be passed manually every time. With this change, provider settings can be managed centrally through .env, which is more
practical for local and Docker-based workflows.

Testing

  • ran python3 -m py_compile autofigure2.py
  • ran docker compose to verify the compose file and env expansion
  • verified that provider env vars are expanded into the container configuration

Notes

  • explicit CLI flags still override env defaults

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.

1 participant