# AI use cases for My Free Code (hkqr/my-free-code)

Repo: [hkqr/my-free-code](https://github.com/hkqr/my-free-code) | Use cases: 4 | Page: https://dedupedai.com/use-cases/hkqr-my-free-code/

My Free Code is an open-source Python gateway that lets Claude Code and other coding agents send requests to many AI model providers and local models through one local address.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Run Claude Code on other model providers: https://dedupedai.com/use-cases/hkqr-my-free-code/run-claude-code-on-other-model-providers/
- Keep agent sessions running when a provider fails: https://dedupedai.com/use-cases/hkqr-my-free-code/keep-agent-sessions-running-with-model-fallbacks/
- Run coding agents against local models: https://dedupedai.com/use-cases/hkqr-my-free-code/run-coding-agents-on-local-models/
- Launch Codex through the local gateway: https://dedupedai.com/use-cases/hkqr-my-free-code/launch-codex-through-the-gateway/

## How to run Claude Code on other model providers with My Free Code

Repo: [hkqr/my-free-code](https://github.com/hkqr/my-free-code) | Difficulty: Intermediate | Time: 30 minutes | Basis: From the README

Route Claude Code requests through a local gateway to the provider models you configure.

**Who it is for:** A developer who uses Claude Code daily and wants to try or pay for models from other providers when a session starts.

**The problem:** Claude Code expects its own model backend, so switching providers normally means changing the agent or giving up its workflow.

**The outcome:** Claude Code runs against a local gateway address, and each Claude tier (Sonnet, Haiku, Opus) maps to the provider model you set in .env.

### Steps

1. Run `python -m venv .venv`, then activate it with `source .venv/bin/activate` on macOS or Linux.
2. Run `python -m pip install -r requirements.txt`.
3. Run `cp .env.example .env`, then set MODEL, MODEL_SONNET, MODEL_HAIKU, and MODEL_OPUS plus the matching provider API keys in .env.
4. Run `python -m my_free_code` in one terminal and keep it running at http://127.0.0.1:8082.
5. Run `python -m my_free_code.cli.mfc claude` in a second terminal to start Claude Code through the gateway.

### Prompt to paste into your agent

```text
Work in the my-free-code repository. Set MODEL_SONNET in .env to <provider/model-id>, start the gateway with python -m my_free_code, then launch Claude Code with python -m my_free_code.cli.mfc claude. Expected output: Claude Code opens and answers a short test prompt. Verify that the gateway log shows a request routed to <provider/model-id>.
```

### Caveat

The project states it is an independent implementation and is not affiliated with Anthropic.

Risk, credentials: Provider API keys are stored in the .env file, so keep .env out of commits and never share it.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/hkqr-my-free-code/run-claude-code-on-other-model-providers/

## How to keep agent sessions running when a provider fails with My Free Code

Repo: [hkqr/my-free-code](https://github.com/hkqr/my-free-code) | Difficulty: Intermediate | Time: 30 minutes | Basis: From the README

Set an ordered fallback list so a failed provider hands the request to the next model.

**Who it is for:** A developer whose coding agent stalls when one hosted provider has an outage or rate limit during a long task.

**The problem:** A single provider failure stops the session, and the developer has to change configuration by hand to continue.

**The outcome:** Requests fall through the configured FALLBACK_MODELS list when a provider fails before output, and the session keeps going.

### Steps

1. Run `python -m venv .venv`, then `python -m pip install -r requirements.txt`, then `cp .env.example .env` as described in the setup section of the README.
2. In .env, set MODEL_SONNET to your primary model and FALLBACK_MODELS to a comma-separated list such as groq/llama-3.3-70b-versatile,ollama/llama3.1.
3. Add the API keys for each provider in the list to .env.
4. Run `python -m my_free_code` and send a test request from Claude Code or another client.
5. Check the gateway output for a failover event before relying on the chain for real work.

### Prompt to paste into your agent

```text
In the my-free-code repository, set MODEL_SONNET to <primary-model> and FALLBACK_MODELS to <fallback-model-1>,<fallback-model-2> in .env, then start the gateway with python -m my_free_code. Expected output: a test request completes using the primary model. Verify that the gateway falls through to the next model when the primary is made to fail before output.
```

### Caveat

The README says fallback only applies before output is committed, so a stream that has already started will not switch providers.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/hkqr-my-free-code/keep-agent-sessions-running-with-model-fallbacks/

## How to run coding agents against local models with My Free Code

Repo: [hkqr/my-free-code](https://github.com/hkqr/my-free-code) | Difficulty: Advanced | Time: 60 minutes | Basis: From the README

Point the gateway at Ollama, LM Studio, or llama.cpp so requests stay on your machine.

**Who it is for:** A developer working offline or with code that cannot leave the machine, who already runs a local model server.

**The problem:** Coding agents are usually wired to hosted APIs, which sends source code to outside providers.

**The outcome:** The gateway forwards agent requests to a local model server at a local base URL, and the agent works without a hosted provider key.

### Steps

1. Start your local model server, such as Ollama at http://127.0.0.1:11434/v1, LM Studio at http://127.0.0.1:1234/v1, or llama.cpp at http://127.0.0.1:8080/v1.
2. Run `cp .env.example .env` and set OLLAMA_BASE_URL, LM_STUDIO_BASE_URL, or LLAMACPP_BASE_URL plus MODEL to the matching local model, such as ollama/llama3.1.
3. Run `python -m my_free_code` to start the gateway.
4. Run `python -m my_free_code.cli.mfc claude` or another launcher command from the README to connect your agent.
5. Confirm the gateway log shows the request reaching your local server rather than a hosted provider.

### Prompt to paste into your agent

```text
In the my-free-code repository, set OLLAMA_BASE_URL and MODEL=ollama/<model-name> in .env, start the gateway with python -m my_free_code, and send one test request. Expected output: a completed response generated by the local model. Verify that no hosted provider key is required for the request to succeed.
```

### Caveat

The README says the gateway is intended for local use, so keep HOST set to 127.0.0.1 and do not expose the Admin endpoints to the Internet.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/hkqr-my-free-code/run-coding-agents-on-local-models/

## How to launch Codex through the local gateway with My Free Code

Repo: [hkqr/my-free-code](https://github.com/hkqr/my-free-code) | Difficulty: Intermediate | Time: 30 minutes | Basis: From the README

Start Codex with the gateway as its backend using the built-in launcher.

**Who it is for:** A developer who uses Codex and wants the same provider routing and fallback that the gateway offers Claude Code.

**The problem:** Each coding client needs its own provider setup, so routing and fallbacks are hard to share across tools.

**The outcome:** Codex runs through the gateway launcher, and its requests use the models and fallbacks configured in .env.

### Steps

1. Run `python -m venv .venv`, then `python -m pip install -r requirements.txt`, then `cp .env.example .env` and set your MODEL and API keys.
2. Install Codex so that the codex command is available on PATH, since the README says the installed client must already exist.
3. Run `python -m my_free_code` in one terminal.
4. Run `python -m my_free_code.cli.mfc codex` in a second terminal.

### Prompt to paste into your agent

```text
In the my-free-code repository, confirm the codex command is on PATH, start the gateway with python -m my_free_code, then run python -m my_free_code.cli.mfc codex. Expected output: Codex starts and completes a short test task. Verify that the gateway log records the request.
```

### Caveat

The launcher only prepares the local proxy environment and passes arguments to the installed client, so Codex must be installed separately.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/hkqr-my-free-code/launch-codex-through-the-gateway/
