Skip to content

feat: support configuring api_key and api_base via environment variables #9484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

thereds11
Copy link

What does this PR do?

  • Adds support for configuring litellm.api_key and litellm.api_base via environment variables LITELLM_API_KEY and LITELLM_API_BASE.

Why is this useful?

  • Helps teams running LiteLLM in containerized or CI/CD environments
  • Improves developer experience by enabling .env or runtime environment injection

What's included:

  • Code change in __init__.py
  • README.md section added under Usage

Happy to iterate on feedback!

Copy link

vercel bot commented Mar 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 6, 2025 8:04pm

Copy link
Contributor

@ishaan-jaff ishaan-jaff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@krrishdholakia
Copy link
Contributor

krrishdholakia commented Mar 25, 2025

Thanks for your work @freshman829. Can you explain the problem a bit more?

You can already set the env var for any provider specific credential

@thereds11
Copy link
Author

Thanks for your work @freshman829. Can you explain the problem a bit more?

You can already set the env var for any provider specific credential

Sure! While litellm allows provider-specific env vars, this change standardizes base-level config (api_key, api_base) across deployments—especially useful in Docker/CI environments where we don’t want to hardcode values or rely on provider-specific keys unless necessary.

@thereds11
Copy link
Author

please add a test here's the checklist: https://docs.litellm.ai/docs/extras/contributing_code#checklist-before-submitting-a-pr

Added unit testing for my update

@CLAassistant
Copy link

CLAassistant commented Apr 22, 2025

CLA assistant check
All committers have signed the CLA.

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.

4 participants