Per-Project API Budgets From Your Terminal
Per-project API budgets from your terminal
My cheapest AI optimization is usually not a better prompt. It is stopping every repository from inheriting the same expensive model. A documentation cleanup, a throwaway migration script, and a production debugging session should not automatically share one spending profile.
Environment variables make that separation boring in the best way. Keep the integration code stable, put routing choices beside each project, and escalate only when the task earns it. Here is the playbook I use to make those choices visible in my terminal.
Separate credentials, routing, and model selection
Fluxo gives this setup one key and one base URL, https://api.fluxorelay.com, across Claude, GPT, Gemini, DeepSeek, Kimi, GLM, Qwen, Grok and more. That removes credential juggling when switching providers. It does not remove the need to choose deliberately: different tasks still deserve different budgets.
I use three application-owned variables: AI_BASE_URL, AI_MODEL, and AI_PROFILE. My application reads those explicitly; they are not magic settings that every CLI recognizes. The credential arrives separately as FLUXO_API_KEY, injected by my shell or secret manager rather than committed to the repository.
For model values, copy the exact API identifier from Fluxo's model listing. Display names are useful for humans, but guessing a slug from a name is an avoidable source of failed requests.
Load a repository profile with direnv
With direnv installed and its shell hook enabled, I put these statements in the repository's .envrc file. The semicolons separate ordinary shell assignments:
export AI_BASE_URL="https://api.fluxorelay.com"; export AI_PROFILE="routine"; export AI_MODEL="REPLACE_WITH_MODEL_ID" — Replace the placeholder before running requests, then inspect the file and run direnv allow. Treat that approval like executing a script, because it is. Never blindly approve environment files from an unfamiliar checkout.
- Keep credentials outside tracked files, including shared project configuration.
- Add local secret files to .gitignore before creating them.
- Commit a credential-free example so teammates understand every required variable.
- Print the active profile and model, never the API key.
Direnv loads the profile when I enter the directory and restores the previous environment when I leave. Without it, a dedicated subshell works too: run bash, export the project settings, launch the tool, and exit afterward. That keeps one project's overrides from leaking into the next.
Map the profile into your SDK or CLI
Fluxo works with Claude Code, Codex, Gemini CLI, and any OpenAI SDK, but those tools do not all read the same variables. Add a small adapter for each tool rather than assuming AI_MODEL controls everything.
For an application using an OpenAI SDK, pass FLUXO_API_KEY as the client's api_key, AI_BASE_URL as its base_url, and AI_MODEL as the request's model. Check Fluxo's integration instructions for any required API path suffix before sending traffic. Keep endpoint-path handling in that adapter, not scattered through business logic.
For a CLI, map the profile into its documented provider, authentication, endpoint, and model settings. Restart long-running editor agents after changing the environment; an existing process generally will not inherit your new exports.
Promote difficult tasks instead of whole repositories
I would trial DeepSeek V4 Flash for routine transformations and evaluate Claude Sonnet 5.5 for harder debugging. Those are candidates, not a universal price or quality ranking. Check current rates and test representative tasks before assigning either role.
For a temporary escalation, use AI_MODEL="REPLACE_WITH_ESCALATION_MODEL_ID" your-command. The override applies to that process and its children without rewriting the repository default.
Measure the bill after retries and cache traffic
Fluxo has no monthly fee and bills per real token, including cache reads and writes. Track those categories alongside input, output, retries, and whether the result passed tests. Compare cost per accepted change, not merely cost per request.
If you want to try this setup, create a Fluxo account and start with one repository. Referral share is earned when people you invite pay; keep that separate from your workload's measured savings. If configuration gets stuck, leave a note on the contact page after signing in.