Switch API Providers When You Change Project Folders
Two project folders, one relay configuration
I want provider selection to follow the repository, not whichever API key I last pasted into my terminal. The application should read its configuration from the environment; switching projects should change that configuration without changing application code.
Fluxo makes this straightforward: one key and one base URL, https://api.fluxorelay.com, cover Claude, GPT, Gemini, DeepSeek, Kimi, GLM, Qwen, Grok and more. We will give two local projects different model settings while keeping the same request code.
If you want to follow along, create a Fluxo account and copy your API key. Run these commands in Bash, including your editor’s integrated terminal.
Create an isolated workspace and load your key
Start with two project directories and a shared virtual environment. This walkthrough requires Python 3, Git, and curl.
mkdir -p fluxo-env-demo/project-a fluxo-env-demo/project-b && cd fluxo-env-demo && git init && python3 -m venv .venv && .venv/bin/python -m pip install openai
Read the key without displaying it or putting its literal value into shell history. Press Enter after pasting it.
read -r -s -p 'Fluxo API key: ' FLUXO_API_KEY; printf '\n'; export FLUXO_API_KEY
The project files below reference this session variable rather than storing the secret. Environment variables are configuration, not a secret vault: child processes inherit exported values, so only run trusted tools in this shell.
Ignore the local configuration files and virtual environment before creating them.
printf '%s\n' '.venv/' '.env.project' >> .gitignore
Discover model IDs before configuring each project
Use Claude Sonnet 5.5 for project A and DeepSeek V4 Pro for project B as concrete examples. Do not assume those display names are API identifiers. Retrieve the available IDs first, then copy the matching identifiers from the response.
curl --fail --silent --show-error https://api.fluxorelay.com/v1/models -H "Authorization: Bearer $FLUXO_API_KEY" | .venv/bin/python -m json.tool
If a display-name mapping is not included, check the model listing in your signed-in dashboard. Use the exact request ID shown there rather than guessing a slug.
read -r -p 'Model ID for project A: ' MODEL_A; read -r -p 'Model ID for project B: ' MODEL_B
Now generate two Bash-compatible configuration files. Bash’s printf %q safely quotes each selected identifier.
for project in project-a project-b; do printf '%s\n' 'export OPENAI_API_KEY="$FLUXO_API_KEY"' 'export OPENAI_BASE_URL="https://api.fluxorelay.com/v1"' > "$project/.env.project"; done; printf 'export OPENAI_MODEL=%q\n' "$MODEL_A" >> project-a/.env.project; printf 'export OPENAI_MODEL=%q\n' "$MODEL_B" >> project-b/.env.project
The relay origin is https://api.fluxorelay.com; the OpenAI-compatible SDK configuration includes the /v1 API prefix. Keep that distinction explicit when configuring other clients.
Run identical SDK code with different environments
Create one shared script. The SDK reads OPENAI_API_KEY and OPENAI_BASE_URL automatically; our script reads OPENAI_MODEL explicitly.
printf '%s\n' 'import os' 'from openai import OpenAI' 'client = OpenAI()' 'print("Selected model:", os.environ["OPENAI_MODEL"])' 'response = client.chat.completions.create(model=os.environ["OPENAI_MODEL"], messages=[{"role": "user", "content": "Write one sentence about project-local configuration."}])' 'print(response.choices[0].message.content)' > ask.py
Run each project inside a subshell. Its environment disappears when the command finishes, preventing one project’s settings from leaking into the next.
(cd project-a && source .env.project && ../.venv/bin/python ../ask.py)
(cd project-b && source .env.project && ../.venv/bin/python ../ask.py)
Each run makes a real, billable request. Fluxo bills per real token, including cache reads and writes, with no monthly fee. A small test prompt keeps configuration checks inexpensive without implying they are free.
Keep editor terminals and CLI settings predictable
- Source only trusted configuration files because sourcing executes shell commands.
- Restart long-running development servers after changing their inherited environment variables.
- Check variable names separately for each command-line client you configure.
- Keep production secrets in your deployment platform’s managed secret storage.
Fluxo also works with Claude Code, Codex, Gemini CLI, and any OpenAI SDK. Their configuration conventions differ; the variables above demonstrate the Python OpenAI SDK, not universal CLI settings.
If teammates adopt the same workflow, users earn a referral share when people they invite pay. For configuration help, leave a note on the contact page after signing in.