Model setup recipes

Connect a Free Open-Weight Model on OpenRouter for Code Review

Send public code and review instructions to OpenRouter and receive a response from an open-weight model.

OpenRouter connects inference1 APIs from multiple model providers through one request format. This recipe pins Meta Llama 3.3 70B Instruct's :free variant to review public Python code and check the request body, free-tier limits, and provider privacy policies.

Requirements and key details
  • A model ID ending in :free is a free endpoint; openrouter/free is a dynamic router that selects a free model for the request.
  • The default OpenRouter free tier allows 20 requests per minute and 50 per day; a cumulative credit purchase of at least $10 raises the daily cap to 1,000.
  • OpenRouter says it does not train on your inputs or outputs, but each request is forwarded to a model provider. Use public code for this review example and check the provider's policy.

Send a public code sample and receive a review

OpenRouter connects inference APIs from multiple model providers through one request format. Send a public code sample and review instructions to receive the model's comments in the response. This guide builds an API2 request that pins the free variant of Llama 3.3 70B Instruct to review a short Python snippet.

Llama 3.3 publishes its weights under the Meta Llama 3.3 Community License. OpenRouter's :free label means hosted API token3 pricing is zero. Meta Llama 3.3 model card · OpenRouter free endpoint

An illustrated workbench connects code on a laptop to several interface panels through a central device
The API sends code and instructions for review, then receives the model's response.

Choose the model ID and free route

A model ID ending in :free is a free hosted variant of that model. openrouter/free is a router that selects a suitable free model for each request, so the actual model can change between calls. For comparable or reproducible code reviews, use a specific free model ID as this example does. Choose openrouter/free when automatic selection matters, while checking weight availability separately. The example's review instruction is written in English.

Send the first request with Python's standard library

You need Python 3, an internet connection, and an API key created in your OpenRouter account. This script sends a request with Python's standard urllib library, so no SDK installation is required. getpass hides the key while you type, keeping it out of command history and source files. This example sends only a short Python function that is safe to make public.

Save the code as review.py and run python3 review.py in a terminal. When prompted, enter your API key and press Enter.

Do not save the key in a shared document or repository. If it has already been exposed, revoke it in the OpenRouter dashboard and create a new key.

Request a review of a public Python function
import getpass
import json
import urllib.request

api_key = getpass.getpass("OpenRouter API key: ")
payload = {
    "model": "meta-llama/llama-3.3-70b-instruct:free",
    "messages": [
        {
            "role": "user",
            "content": (
                "Review this public Python example for correctness. State one concrete issue, "
                "if any, and suggest a minimal fix:\n\n"
                "def percentage(part, total):\n"
                "    return part / total * 100\n"
            ),
        }
    ],
    "max_tokens": 200,
}
request = urllib.request.Request(
    "https://openrouter.ai/api/v1/chat/completions",
    data=json.dumps(payload).encode("utf-8"),
    headers={
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json",
    },
    method="POST",
)
with urllib.request.urlopen(request, timeout=60) as response:
    result = json.load(response)
print(result["choices"][0]["message"]["content"])
The request body contains the model ID and public code; the API key is read only at the prompt.

Recognize a response and diagnose the first error

On success, the terminal prints the code review. The response JSON stores it at choices[0].message.content and may include token details in usage, but the current script prints only the review.

To display token details too, add print(result.get("usage")) on the line after print(result["choices"][0]["message"]["content"]) at the end of the script.

The model may point out division by zero when total is 0 and suggest a guard, but verify every suggestion against the code and tests.

For HTTP Error 401, check that the key is correct and active, and that a space follows Bearer. HTTP Error 429 can mean you reached the 20-per-minute or daily request limit. Stop retry loops and reduce calls until the free allowance resets. For No endpoints found or a model error, check whether that :free endpoint is currently available and whether your requested features and provider filters match; then choose an available free model ID.

A monitor connected to a compact desktop computer shows a code editor beside a chat panel
Set the model ID, messages, and output limit in the request.

Keep costs at zero within the daily free limit

As of October 16, 2026, OpenRouter's pricing page lists 20 free-model requests per minute and 50 per day for a default account. Failed requests count toward the daily limit. Buying at least $10 in credits raises the free-model cap to 1,000 requests per day. If you are testing within the free tier, leaving credits unpurchased makes costs easier to control.

OpenRouter free-model request limits · checked October 16, 2026
Account conditionFree-model limitWhat to verify
Default free account20 per minute · 50 per dayFailed requests count toward the daily cap
At least $10 in credits purchased20 per minute · 1,000 per dayExisting cumulative purchase threshold

Keep the model string meta-llama/llama-3.3-70b-instruct:free in this example, and check the listed price whenever choosing another model. An ID such as meta-llama/llama-3.3-70b-instruct without :free may be a paid route. The OpenRouter Free plan lists no budget or spend-control feature, so do not add credits or enable auto top-up while testing; check Activity for the model used and its cost. Do not add a paid model as an automatic fallback.

Control what code and personal data reach model providers

OpenRouter says it does not use inputs or outputs to train its own models, but it forwards requests to the selected model provider. Provider retention and training policies can differ, so read the provider details on the Llama 3.3 page and send only public code. OpenRouter privacy policy · Llama 3.3 free endpoint

To apply a provider filter, add a provider setting to the request body. data_collection: "deny" excludes providers that collect data, while zdr: true selects only providers with a Zero Data Retention policy.

Stop the request if no free provider meets the filter, and do not configure a fallback to a paid model. In the Python example, add the code after creating payload and immediately before the request = urllib.request.Request( line. Provider data collection controls

Optional privacy filters to add after payload and before the API request
payload["provider"] = {
    "data_collection": "deny",
    "zdr": True,
}
These filters can cause a request to fail when no eligible free provider is available.

Choose what to test with the free API and when to use another route

The free API suits requests within the daily 50-call allowance, such as asking for possible bugs in public code or refining a prompt4 and output format.

If your request volume grows or you need consistent latency, provider selection, and retention controls, compare the current model pages and paid-plan controls. For internal code that must stay within your repository without inference charges, a local model is a better fit. Free models and providers can change, so review the free-model collection and pricing and limits before adopting a route.

A desk monitor displays a chat panel and code editor side by side
Keep the model's answer beside the code while checking its suggested changes.

Terminology notes

  1. Inference — The process of using a trained model to compute an output for an input. Here, local inference means running the model on the user’s device.

    Back to the text
  2. API — A defined interface that lets other code call a program’s functions.

    Back to the text
  3. Token — A unit into which a model divides input or output for processing.

    Back to the text
  4. Prompt — The input text sent to a model. For generative models it describes the desired result and strongly shapes the output.

    Back to the text

Frequently asked questions

What should you check first in this article?
OpenRouter connects inference APIs from multiple model providers through one request format. This recipe pins Meta Llama 3.3 70B Instruct's `:free` variant to review public Python code and check the request body, free-tier limits, and provider privacy policies.
When is it better not to choose this?
Do not save the key in a shared document or repository. If it has already been exposed, revoke it in the OpenRouter dashboard and create a new key.
Where can you check the conditions and sources?
Llama 3.3 publishes its weights under the Meta Llama 3.3 Community License. OpenRouter's `:free` label means hosted API token pricing is zero. [Meta Llama 3.3 model card](https://huggingface.co/meta-llama/Llama-3.3-70B-Instruct) · [OpenRouter free endpoint](https://openrouter.ai/meta-llama/llama-3.3-70b-instruct:free)