Configure Your Editor to Route Requests via freeapigemini.com

Editors and CLI tools often hardcode specific model names like "gemini-pro" or "gemini-1.5-pro" into their configuration files. When you switch to a free, keyless API, these hardcoded strings cause immediate failures because the backend does not recognize them. Understanding how to decouple the editor’s model selector from the actual API endpoint is the first step in gaining reliable, quota-free access to large language models. This guide explains how to point your coding assistant to the free-ai model, which is an independent open-weight model and is not affiliated with Google.
By defining a custom endpoint, you redirect your editor’s HTTP requests to a server that accepts standard OpenAI-compatible payloads. This method works with any tool that allows you to specify a base URL and model name. It is particularly useful when you encounter the quota reset issues described in Why Do CLI Quotas Reset at Weird Times? or when you need to bypass the limitations of the official Gemini CLI. The free endpoint provides a simple way to test models without managing API keys or worrying about daily usage caps.
This guide walks you through the technical configuration required to point your editor at the freeapigemini.com infrastructure. We will cover the specific headers, model identifiers, and connection settings needed to ensure your coding assistant communicates correctly. This approach is distinct from using the web interface, as detailed in AI Studio vs Gemini Web: Which Handles Context Better?, and offers a more direct path to programmatic access for developers who want flexibility without the overhead of enterprise plans.
Frequently asked questions
What is a custom endpoint in editor configuration?
A custom endpoint is a base URL that your editor uses to send API requests instead of the default provider’s URL. By overriding this setting, you can route your prompts to a third-party server that supports the OpenAI chat completion format, allowing you to use different models or free tiers without changing your editor’s core logic.
How does the free-ai model differ from the official Gemini Pro model?
The free-ai model is an independent open-weight model with approximately 35B parameters, fine-tuned to refuse fewer prompts than commercial assistants. Unlike the official Gemini Pro model, it does not rely on Google’s proprietary infrastructure, meaning it has different strengths in reasoning and a distinct quota system that resets daily at 00:00 UTC.
Why do I get 403 errors when using Python urllib?
Python’s default urllib user-agent string is often blocked by API gateways to prevent automated scraping. To fix this, you must explicitly set a standard User-Agent header in your request, such as identifying your editor or operating system. Without this header, the server assumes you are a bot and returns a 403 Forbidden error.
Which is better: using the official API or the free endpoint?
The official API offers higher quality, multimodal capabilities, and an SLA, but comes with strict quotas and billing. The free endpoint provides unlimited access to a capable 35B model with no API key required, making it ideal for development and testing, though it lacks image support and has lower rate limits per IP.
What is the base URL for the free endpoint?
The base URL for the free, keyless API is https://api.freeapigemini.com/v1. You should configure your editor to use this URL as the base path for all chat completion requests. This endpoint is compatible with the standard OpenAI chat format, allowing you to use existing tools and SDKs without modification.
How do I handle streaming responses in my editor?
Streaming responses are delivered as Server-Sent Events (SSE). Your editor must parse the incoming stream, extracting the content tokens from each SSE frame. The stream ends with a specific completion marker, usually "data: [DONE]", indicating that the model has finished generating the response. Most modern editors handle this automatically once the endpoint is configured.
What happens if I hit the rate limit?
If you exceed the limit of one request per second or the daily quota, the API returns a 429 Too Many Requests status code. The response includes a Retry-After header indicating how long to wait. If the server is busy, you may receive a 503 Service Unavailable error, requiring a short retry delay of 2-5 seconds.
Can I use the free endpoint for coding assistants?
Yes, the free endpoint is fully compatible with coding assistants like Cursor, Continue, or Codeium. You simply need to update the base URL and model name in the assistant’s settings. This allows you to enjoy a keyless, free experience for code generation, refactoring, and explanation without worrying about daily token limits.
Step by step
- Update Base URL — Navigate to your editor’s API settings and update the base URL to https://api.freeapigemini.com/v1. Ensure that the model name is set to "free-ai".
- Set Dummy API Key — Enter a dummy value like "free" in the API Key field. This satisfies the editor’s requirement for a key without affecting the free endpoint’s functionality.
- Configure User-Agent — Add a standard User-Agent header to your request, such as "MyEditor/1.0", to avoid 403 errors. This is crucial for Python-based editors and custom scripts.
- Test Connection — Send a test request to the /health endpoint or use a simple chat prompt to verify that your editor is correctly routing requests to the free endpoint.
- Enable Streaming — Ensure that streaming is enabled in your editor’s settings to receive real-time token updates. This provides a smoother user experience during text generation.
Understanding the Endpoint Architecture
The architecture of modern AI editors relies on a clear separation between the user interface and the backend model. When you type a prompt in your editor, the client software serializes the request into a JSON payload and sends it to a specific base URL. By default, most editors are pre-configured to send these requests to Google’s official Gemini API or OpenAI’s servers. This default configuration assumes you have a valid API key and a specific model identifier, such as "gemini-pro" or "gpt-4".
However, when you want to use the freeapigemini.com service, you are essentially bypassing the official provider’s infrastructure. The free endpoint accepts the same JSON structure but processes it using a different model, free-ai. This model is an independent 35B parameter open-weight model that has been fine-tuned to be more permissive than commercial assistants. It does not require an API key, which simplifies the setup process significantly, but it does require you to explicitly define the base URL in your editor’s configuration.
The Role of the Base URL
The base URL is the foundation of your API connection. It tells your editor where to send the HTTP POST requests. For the free endpoint, this URL is https://api.freeapigemini.com/v1. This path includes the version identifier "v1", which is standard for OpenAI-compatible APIs. Your editor will append the endpoint path, such as /chat/completions, to this base URL to form the complete request URI.
Model Identification Strings
Even though you are not using Google’s models, you still need to specify a model name in your request. The free endpoint expects the model name to be "free-ai". If you leave this as "gemini-pro", the server may reject the request or route it incorrectly. You must ensure that your editor’s configuration file or settings menu explicitly sets the model name to "free-ai" to avoid confusion.
import openai
client = openai.OpenAI(
base_url="https://api.freeapigemini.com/v1",
api_key="dummy-key", # Key is not validated, but field is required
default_headers={
"User-Agent": "MyEditor/1.0"
}
)
response = client.chat.completions.create(
model="free-ai",
messages=[{"role": "user", "content": "Explain quantum entanglement."}]
)
print(response.choices[0].message.content)Configuring the Base URL in Common Editors
Most popular AI coding editors allow you to customize the API endpoint through their settings interface. For example, in Cursor, you can navigate to the settings menu and look for the API configuration section. Here, you will find fields for the API Key and the Base URL. Since the free endpoint does not require a key, you can enter any dummy string into the API Key field, such as "none" or "free", as long as the field is populated. The critical part is entering the correct base URL.
In Continue, the configuration is handled via a JSON file named "continue.json". You will need to add a new provider of type "openai" and specify the base URL as "https://api.freeapigemini.com/v1". You should also set the model to "free-ai". This configuration ensures that all subsequent requests from your editor are directed to the free server. If you have previously configured a Google provider, you can either replace it or add a new provider, depending on your workflow preferences.
Cursor Configuration Steps
Open Cursor and go to Settings > AI > Providers. Add a new provider of type "OpenAI". Set the Base URL to "https://api.freeapigemini.com/v1" and the API Key to any value. Set the Model to "free-ai". Save the changes and restart the editor if necessary. This setup will allow you to use the free endpoint for all your coding tasks within Cursor.
Continue Configuration Steps
Open your project’s root directory and edit the "continue.json" file. Add a new provider entry under the "providers" array. Set the type to "openai", the model to "free-ai", and the baseUrl to "https://api.freeapigemini.com/v1". Ensure that the apikey field is present, even if it is empty or a dummy value. This configuration will route your requests through the free endpoint, bypassing any quota limits associated with the official Gemini API.
{
"providers": [
{
"model": "free-ai",
"apiType": "openai",
"apiKey": "none",
"baseUrl": "https://api.freeapigemini.com/v1"
}
]
}
Handling API Keys and Headers
Although the free endpoint does not validate API keys, many editors and SDKs require the apikey field to be present in the request headers. This is because the OpenAI format standardizes the header name as "Authorization: Bearer <key>". If the field is missing, some editors may fail to construct the request correctly. You can use a placeholder value like "free" or "dummy" to satisfy this requirement. The server will ignore the key value and process the request based on the IP address and rate limits.
Another critical header is the User-Agent. As noted in the documentation, Python’s default urllib user-agent is often blocked by API gateways. If you are using a custom script or a less common editor, you should ensure that a standard User-Agent header is included. This header helps the server identify the client and apply the appropriate rate limits. Without a proper User-Agent, you may encounter 403 Forbidden errors, which can be confusing if you are not aware of this requirement.
Setting the User-Agent Header
To avoid 403 errors, explicitly set the User-Agent header in your editor or script. For example, in Python, you can pass the header as a dictionary in the client initialization. In editor settings, look for a custom headers field and add "User-Agent: MyEditor/1.0". This simple step ensures that your requests are treated as legitimate client traffic rather than automated scraping.
Managing Dummy API Keys
When configuring your editor, you will likely need to provide an API key even if it is not used. Use a simple placeholder like "free" or "none" in the API Key field. This ensures that the editor constructs the Authorization header correctly. The free endpoint does not check the validity of this key, so any string will work as long as the field is not empty.
{
"headers": {
"User-Agent": "MyEditor/1.0",
"Authorization": "Bearer free"
}
}Streaming Responses and SSE
Modern editors rely on streaming responses to provide a smooth user experience. Instead of waiting for the entire response to be generated, the editor displays tokens as they become available. This is achieved using Server-Sent Events (SSE). The free endpoint supports streaming by including the "stream": true parameter in your request. The server will then send a series of SSE frames, each containing a portion of the response.
Your editor must parse these SSE frames to extract the content tokens. Each frame typically contains a JSON object with a "choices" array, where the first element contains the delta content. The stream ends with a special frame indicating completion, usually "data: [DONE]". Most editors handle this parsing automatically, but if you are building a custom client, you will need to implement the SSE parser yourself.
Enabling Streaming in Editors
In your editor’s configuration, ensure that streaming is enabled. In Cursor, this is usually the default. In Continue, you may need to check the "stream" option in the provider settings. This ensures that the editor requests the "stream": true parameter in the API call, allowing for real-time token display.
Parsing SSE Frames
If you are using a custom script, you can use the requests library in Python to handle SSE. Iterate over the response line by line, checking for lines that start with "data: ". Parse the JSON payload within each line to extract the content delta. Stop when you encounter the "[DONE]" marker. This approach ensures that you can handle streaming responses correctly without relying on a specific SDK.
import requests
import json
response = requests.post(
"https://api.freeapigemini.com/v1/chat/completions",
json={
"model": "free-ai",
"messages": [{"role": "user", "content": "Hello"}],
"stream": True
},
headers={"User-Agent": "MyEditor/1.0"}
)
for line in response.iter_lines():
if line.startswith(b'data: '):
data = line[6:].decode('utf-8')
if data == '[DONE]':
break
print(json.loads(data)['choices'][0]['delta'].get('content', ''), end='')
Rate Limits and Quotas
The free endpoint has specific rate limits to ensure fair usage. You are limited to one request per second, with bursts of up to three requests allowed. Additionally, you can have up to two parallel requests. The daily quota is 10,000 requests or 10,000,000 tokens, whichever comes first. These limits reset at 00:00 UTC. If you exceed these limits, you will receive a 429 status code with a Retry-After header.
It is important to monitor your usage to avoid unexpected interruptions. If you are using multiple editors or CLI tools, they all share the same IP-based limits. This means that if you are using both Cursor and a CLI tool from the same IP address, they will compete for the same quota. This is a common issue, as discussed in Why Do CLI Quotas Reset at Weird Times?.
Understanding Burst Limits
The burst limit of three requests per second allows for quick interactions, such as typing in a chat interface. However, if you send four requests within one second, the fourth will be rejected with a 429 status code. Your editor should handle this gracefully by retrying after the specified delay.
Managing Parallel Requests
The limit of two parallel requests means that you can have two active connections to the API at any given time. If you try to open a third, it will be queued or rejected. This is useful for editors that support multiple chat windows or parallel code generation tasks.
{
"error": {
"message": "Rate limit exceeded",
"type": "rate_limit",
"code": 429
}
}Troubleshooting Common Issues
One of the most common issues when switching to a custom endpoint is the 403 Forbidden error. This is usually caused by a missing or incorrect User-Agent header. As mentioned earlier, Python’s default urllib user-agent is often blocked. Ensure that your editor or script includes a standard User-Agent string. If you are using a CLI tool, check its documentation for how to set custom headers.
Another issue is the model name mismatch. If you leave the model name as "gemini-pro", the server may reject the request because it does not recognize the model. Always set the model name to "free-ai" in your editor’s configuration. This ensures that the server knows which model to use for processing your request.
Fixing 403 Errors
To fix 403 errors, add a standard User-Agent header to your request. In Python, you can do this by passing a dictionary of headers to the client. In editor settings, look for a custom headers field and add "User-Agent: MyEditor/1.0". This simple change can resolve many connectivity issues.
Resolving Model Name Errors
Ensure that the model name in your editor’s configuration is set to "free-ai". If you are using a CLI tool, check the command-line arguments for the model flag. Using the wrong model name will result in a 404 or 400 error, as the server will not recognize the requested model.
# Example CLI command with correct model and user-agent
curl -X POST https://api.freeapigemini.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "User-Agent: MyCLI/1.0" \
-H "Authorization: Bearer free" \
-d '{
"model": "free-ai",
"messages": [{"role": "user", "content": "Hello"}]
}'
Advanced Configuration Options
For power users, the free endpoint supports additional parameters that can enhance the quality of the responses. You can enable reasoning by setting the "reasoning": true parameter in your request. This may improve the model’s ability to handle complex tasks, but it also increases the token count and may require a higher max_tokens value. The default max_tokens is usually sufficient for most tasks, but you can increase it if needed.
You can also adjust the temperature and other sampling parameters to control the creativity of the model. A lower temperature will result in more deterministic responses, while a higher temperature will produce more varied and creative outputs. These parameters are passed in the JSON payload of your request, just like the model name and messages.
Enabling Reasoning Mode
To enable reasoning mode, add the "reasoning": true parameter to your request. This may improve the model’s performance on complex tasks. Note that this may increase the token count, so ensure that your max_tokens setting is high enough to accommodate the additional output.
Adjusting Sampling Parameters
You can adjust the temperature and other sampling parameters to control the model’s behavior. Set the temperature to a value between 0 and 1 to control the randomness of the output. A lower value will produce more deterministic responses, while a higher value will produce more varied outputs. These parameters are passed in the JSON payload of your request.
{
"model": "free-ai",
"messages": [{"role": "user", "content": "Solve this problem"}],
"reasoning": true,
"temperature": 0.7,
"max_tokens": 2000
}Integrating with Third-Party Tools
The free endpoint is compatible with a wide range of third-party tools and libraries. You can use the OpenAI Python SDK, the requests library, or any other tool that supports the OpenAI chat completion format. This flexibility allows you to integrate the free endpoint into your existing workflows without significant changes. For example, you can use the endpoint with LangChain, LlamaIndex, or other AI frameworks.
If you are using a CLI tool like gemini-cli or antigravity-cli, you can configure them to use the free endpoint by updating their configuration files. This allows you to access the free-ai model directly from your terminal, bypassing the official API’s quota limits. This is particularly useful for developers who need to perform bulk operations or run long-running scripts.
Using the OpenAI SDK
The OpenAI Python SDK is fully compatible with the free endpoint. Simply initialize the client with the correct base URL and model name. The SDK will handle the request formatting and response parsing, making it easy to integrate the free endpoint into your Python applications.
Configuring CLI Tools
For CLI tools, update the configuration file to point to the free endpoint. In gemini-cli, you may need to edit the config.yaml file to set the base URL and model. In antigravity-cli, follow similar steps. This allows you to use the free endpoint directly from your terminal, providing a seamless experience for command-line workflows.
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
base_url="https://api.freeapigemini.com/v1",
api_key="free",
model="free-ai",
temperature=0.7
)
response = llm.invoke("Explain the theory of relativity.")
print(response.content)
Best Practices and Recommendations
When using the free endpoint, it is important to be mindful of the rate limits and quotas. If you are running multiple editors or CLI tools from the same IP address, they will share the same limits. Monitor your usage to avoid hitting the cap unexpectedly. You can use the /health endpoint to check the status of the API and ensure that it is operational.
Another best practice is to use reasonable max_tokens values. The free endpoint supports up to 16,000 tokens for the response, but using a lower value can help prevent excessive token usage and improve response times. If you need longer responses, consider breaking your prompt into smaller chunks or using a context compaction strategy, as discussed in Does Gemini Delete Messages to Save Context?.
Monitoring Usage
Keep an eye on your token usage to avoid hitting the daily quota. You can use the /health endpoint to check the API status and ensure that it is operational. If you notice that you are frequently hitting the rate limit, consider staggering your requests or using a different IP address if possible.
Optimizing Token Usage
Use reasonable max_tokens values to prevent excessive token usage. If you need longer responses, consider breaking your prompt into smaller chunks or using a context compaction strategy. This will help you stay within the quota limits and improve the overall performance of your application.
# Check API health
curl https://api.freeapigemini.com/health
# Check available models
curl https://api.freeapigemini.com/v1/modelsTest the keyless endpoint with your own code samples right now to see how it handles your specific requests.