Skip to content

Add MISTRAL_ environment variable support with precedence over KOYEB_#56

Draft
nicoche wants to merge 1 commit into
mainfrom
vibe/mistral-env-vars-b87236
Draft

Add MISTRAL_ environment variable support with precedence over KOYEB_#56
nicoche wants to merge 1 commit into
mainfrom
vibe/mistral-env-vars-b87236

Conversation

@nicoche

@nicoche nicoche commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add support for MISTRAL_ environment variables as counterparts to KOYEB_ variables
  • MISTRAL_API_TOKEN, MISTRAL_API_HOST, and MISTRAL_REGION now take precedence over KOYEB_ counterparts
  • Add helper functions in utils.py for consistent environment variable access
  • Update all relevant code, documentation, and examples

Changes Made

Core Changes

  • Added get_env_var_mistral_fallback(), get_api_token(), get_api_host(), and get_region() helper functions in koyeb/sandbox/utils.py
  • Updated get_api_clients() and get_async_api_clients() to use the new helper functions
  • Updated create_deployment_definition() to use get_region() helper
  • Updated sandbox.py to use get_api_token() helper and updated all docstrings
  • Updated snapshot.py to use get_api_token() helper and updated docstrings

Documentation & Examples

  • Updated docs/sandbox.md to mention both MISTRAL_ and KOYEB_ environment variables
  • Updated examples/README.md to show both environment variable options
  • Updated example files to check for MISTRAL_API_TOKEN first, then KOYEB_API_TOKEN

Behavior

  • When both MISTRAL_ and KOYEB_ variables are set, MISTRAL_ takes precedence
  • When only KOYEB_ variables are set, they continue to work as before (backward compatible)
  • When only MISTRAL_ variables are set, they are used
  • Error messages now mention both variable names when neither is set

Testing

  • All imports work correctly
  • Helper functions tested for precedence behavior
  • Integration with API client functions verified
  • Backward compatibility maintained

Closes: Request to add MISTRAL_ environment variable support

- Add helper functions (get_api_token, get_api_host, get_region) in utils.py
- Update get_api_clients() and get_async_api_clients() to check MISTRAL_ vars first
- Update sandbox.py and snapshot.py to use the new helper functions
- Update documentation and examples to mention both MISTRAL_ and KOYEB_ env vars
- MISTRAL_API_TOKEN, MISTRAL_API_HOST, and MISTRAL_REGION take precedence over KOYEB_ counterparts

This allows users to use either MISTRAL_ or KOYEB_ environment variables, with
MISTRAL_ variables taking precedence when both are set.

Co-authored-by: nicoche <nicoche@users.noreply.github.com>
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