One-line curl calls for scripts, pipes and cron jobs

A shell user wants something simple: type a question, get text back, pipe it into the next command. Here is what a Gemini key involves, and a keyless endpoint whose /ask route works with nothing but curl.

  • curl only
  • No secret in dotfiles
  • Plain text output
  • Text only, no SLA

FreeKeyAPIGemini editorial team · Updated 2026-11-16

Terminal window running a curl command and printing a short plain text answer
curl, a URL-encoded question and plain text on standard output.

Command-line people tend to want AI in the smallest possible form. Not an IDE plugin, not a chat app, just a way to ask a question from a terminal, summarize a log file, write a commit message or explain a confusing error. The search for a free Gemini API key often starts here, because Google's free tier and its command-line tooling are well known among developers.

This page compares the two routes honestly. Calling Gemini from a shell means a key from Google AI Studio, an environment variable and quota you have to watch. The other route is an independent keyless API on this site, where curl "https://api.freekeyapigemini.com/ask?q=hello" returns plain text. The model there is free-ai, a small open-weight model that is not Gemini.

Terminal, curl and Gemini key questions

How do I call the Gemini API with curl?

Create a key in Google AI Studio, export it as an environment variable, and send a JSON POST to the generate content endpoint described in Google's documentation, passing the key in a header. Google's docs show a working curl example per model. Keep the key out of shell history by reading it from a file or a secret manager.

Is there a free tier for calling Gemini from scripts?

Yes, the Gemini API has a free tier with per-model rate limits, set by Google and changed over time. Scripts that loop can hit those limits fast, and the free coding-agent and CLI offers around Gemini have also changed. Check Google's current pricing and rate limit pages before you automate anything important.

What is the shortest keyless call here?

curl "https://api.freekeyapigemini.com/ask?q=what+is+a+zombie+process". The answer comes back as plain text, ready to print or pipe. Add &format=json if a script prefers JSON. For anything longer than a line, use --data-urlencode so spaces and symbols are encoded correctly.

Is free-ai a Gemini model?

No. free-ai is an independent open-weight model of about 35B parameters, fine-tuned to refuse far less than commercial assistants. It is not Gemini or any other Google model. It is good at short explanations, shell one-liners, summaries and rewriting. Gemini models are much larger and better at hard reasoning and long code.

Can I pipe a log file into it?

Yes, as long as the text fits. Context is 32,000 tokens per request. For a long log, send only the last lines with tail or filter with grep first. Use the chat completions endpoint with jq to build the JSON body, since a URL is a poor place for many kilobytes of text.

What about tools that drive the Gemini web app instead of the API?

Some projects automate the consumer chat page so scripts can use it with no key. They break when the page changes, may violate the consumer terms and can put your Google account at risk. They are curiosities, not something to run in cron. A keyless endpoint meant for API use is more stable.

What are the rate limits for shell scripts?

Per IP: 1 request per second with bursts of 3, 2 parallel requests, and 10,000 requests or 10,000,000 tokens per day, reset at 00:00 UTC. Answers can be up to 16,000 tokens. On 429, sleep for the Retry-After value; on 503, wait two to five seconds and retry.

Are proxies that rotate many free Gemini keys a good idea?

Rotating several free keys to multiply a quota usually goes against the provider's terms and tends to get projects suspended. Rotating keys found online is worse, because those keys belong to someone else. Use one key you own within its limits, or a service that needs no key.

What does this API log about my commands?

Each request leaves a technical log: time, IP, User-Agent, country, endpoint, status, latency, sizes and token counts. The IP enforces limits. The API is stateless. Do not pipe secrets, private keys, environment dumps or customer data into it; scrub logs before sending them.

Independent service. FreeKeyAPIGemini is not affiliated with Google and does not issue or share Gemini keys. The free-ai model answering here is not Gemini or any other Google model.

Crossed-out key icon: no API key is needed
No key: nothing to export, rotate or leak
Plug connector icon for OpenAI-compatible clients
OpenAI-compatible: SDKs and CLIs that accept a base URL
Browser window icon calling the API directly
Works in the browser: CORS open for any origin
Globe icon with letters from several languages
Many languages: ask in your own language
Lightning bolt over a speedometer for fast replies
Fast: 100+ tokens per second on typical replies

Your first terminal call in five steps

All you need is curl, which ships with most systems. jq helps for JSON work but is optional.

Numbered steps from one to three
Start with /ask for quick questions; use chat completions when scripts need control.
  1. Check the service

    Run curl https://api.freekeyapigemini.com/health. A quick success response means the endpoint is up.

  2. Ask a one-line question

    Use curl -G https://api.freekeyapigemini.com/ask --data-urlencode "q=explain chmod 750" and read the plain text reply.

  3. Wrap it in a function

    Add a small ask() function to your shell profile that passes its arguments as the question. No key goes into the file.

  4. Use JSON for scripts

    Build a body with jq -n and POST it to /v1/chat/completions with model free-ai; read .choices[0].message.content.

  5. Add retries

    Use curl --retry or a loop that honors Retry-After on 429 and sleeps a few seconds on 503.

Getting Gemini into a shell: the key-based route

The standard way to call Gemini from a terminal starts in Google AI Studio. You sign in, create an API key attached to a Cloud project, and export it in your shell, usually as an environment variable. From there you can use curl against the REST endpoint in Google's documentation, Google's SDKs, or one of the community command-line tools built on top of them. Google has also published its own command-line agent for coding work.

Free access to those tools is a moving target. The Gemini API's free tier has per-model limits, and free plans for coding assistants and command-line agents have been changed and in some cases scaled back. Students and certain plan holders have been offered extra access from time to time. None of that is a stable foundation for a script you will forget about for a year, so check Google's current pages.

Where the key lives

Keep it in a file readable only by you, or in a password manager CLI, and load it at runtime. Avoid putting it directly in a profile that ends up in a dotfiles repository.

What it costs

Beyond the free tier, usage is billed through Cloud. Set a budget alert before a loop or a cron job can run up charges.

Code editor with a Python script using the OpenAI client
A key in the environment is convenient, and easy to leak through dotfiles.

The keyless /ask route in one command

This site offers a different shape of API. GET /ask?q= takes a question in the query string and answers with plain text, no JSON, no headers, no key. That makes it the smallest possible AI call: curl -sG https://api.freekeyapigemini.com/ask --data-urlencode "q=what does set -euo pipefail do". The answer prints straight to standard output, ready for less, tee or a file.

Add &format=json when a script needs structure. Behind the route sits free-ai, an open-weight model of about 35B parameters fine-tuned to refuse far less often than commercial assistants, with two hard rules: no sexual content involving minors and no operational instructions for mass-casualty weapons. It is not Gemini and is not connected to Google in any way.

Use -G and --data-urlencode

This pair makes curl encode the question for you, so quotes, ampersands and spaces in the prompt do not break the URL.

Silence progress output

Add -s so curl does not print a progress meter into your pipeline, and -f so HTTP errors return a non-zero exit code.

Illustration of code brackets and a developer tools panel
No headers and no key: the smallest AI request a shell can make.

Ask before you script it

Try a question here to see the kind of answer /ask gives in the terminal. No key and no login; API limits apply.

freekeyapigemini engine8 live panels

Every request, live. One real day of the free-ai API, 1 Dec, replayed second by second.

REPLAY · --:--:-- UTC · 1 Dec
  • Answers so far55,510of 55,510 on 1 Dec
  • Tokens read489Mprompts + history
  • Tokens written46.0Mmodel replies
  • Answer time3.0 smedian · p90 15.6 s
  • Speed22 tok/smedian · p90 34
  • Since 10 Nov509Kanswers · peak 61.0K
01

Live requests

one node = one real request · grouped by prompt sizeLOADING
  • prompt < 1K tokens0
  • prompt 1K–4K0
  • prompt 4K–16K0
  • prompt 16K+0
  • since you opened · 1 Dec
zoom 100% · nodes 0 · links 0 · signals 0
02

Request log

no prompt textLOADING
$ tail -f requests.log
    03

    Request lifecycle

    one sampled request · real timingLOADING
    1. request receivedok
    2. per-IP limitok
    3. safety checkpass
    4. routed to modelfree-ai
    5. generating
    6. answer returned
    04

    24 hours

    answers per hour, UTCLOADING
    5,149peak hour 03:00 UTC
    0006121824
    05

    Day by day

    answers per dayLOADING
    509,307answers since 10 Nov
    11-1012-01
    06

    Speed

    output tokens per second, streamed repliesLOADING
    median
    22 tok/s
    fastest 10%
    34+ tok/s
    needle
    sampled requests
    07

    Answer time

    full reply, all requestsLOADING
    3.0 smedian
    02 s6 s15 s30 s+
    08

    Plug in

    OpenAI-compatible · no keyLOADING
    curl https://api.freekeyapigemini.com/v1/chat/completions -H "Content-Type: application/json" -d '{"model":"free-ai","messages":[{"role":"user","content":"Hi"}]}'
    • Base URLhttps://api.freekeyapigemini.com/v1
    • Modelfree-ai, open-weight, about 35B
    • Keynot needed
    • Limitsper IP

    Data: the request log of the free-ai API that serves this site and the other sites of the same service, all together, for 1 Dec 2026 (UTC): successful answers only, automated bot traffic excluded. The log keeps counts, token sizes and timings; this panel shows no prompt text, no sites and no visitors. The live panels replay that day at real speed: one node or log line is one request made that day at this time of day.

    Shell functions and aliases worth keeping

    A short function in your shell profile turns the endpoint into a command. Define ask() to join its arguments into a question and call /ask with curl. Now ask how do I find files larger than 1GB works anywhere. Because there is no key, the function is safe to commit to a public dotfiles repository and to copy onto servers.

    Small variations cover most daily uses. A function that reads standard input lets you pipe text in. Another can prepend a fixed instruction, such as "reply with only a shell command, no explanation", so the output is easy to review and paste. Always read a generated command before running it; a small model can be confidently wrong about flags.

    • ask: a question from arguments, plain text answer
    • explain: pipe an error message in, get a short explanation
    • cmd: describe a task, get a single shell command back
    • tldr: pipe a long text in, get a five-line summary
    • commitmsg: pipe git diff --staged in, get a commit message draft
    Diagram from your app to the gateway, the GPU model and the answer
    Helpers without a key are safe to share in public dotfiles.

    Pipes: logs, diffs and command output

    The real power in a terminal is the pipe. You can send the tail of a log, the output of a failed build or a staged diff to the model and ask what went wrong. For anything larger than a sentence, switch from /ask to POST /v1/chat/completions. Use jq -Rs to turn standard input into a JSON string and jq -n to build the request body safely.

    Keep inputs focused. The context window is 32,000 tokens, which is a lot of text but not an entire log directory. Filter first with grep, tail -n 200 or awk, and tell the model what you are looking for. Smaller inputs give faster, better answers and use less of the daily token budget.

    Scrub before you send

    Logs often contain tokens, internal hostnames, emails and IP addresses. Run a quick sed filter to mask them before piping anything to a third-party API.

    Ask a specific question

    "Which line explains the crash and why?" gets a better answer than "look at this". Name the language, tool or framework involved.

    Text tokens arriving one by one as the model writes
    jq turns piped text into a safe JSON body for the chat endpoint.

    Copy and paste into a terminal

    Each tab sends the same question to https://api.freekeyapigemini.com/v1 with model free-ai. The GET /ask tab is the plain curl one-liner. Any key value is ignored.

    curl https://api.freekeyapigemini.com/v1/chat/completions \
      -H "Content-Type: application/json" \
      -d '{"model":"free-ai","messages":[{"role":"user","content":"What does the tar flag -xzvf do?"}]}'

    Window with a JSON response from the API including the generated text
    A response in Chat Completions format

    Cron jobs and unattended scripts

    Scheduled scripts are a natural fit: a nightly summary of new error lines, a weekly digest of a changelog, a morning note listing open pull requests in plain English. Because there is no key, a cron job has no secret that can expire or leak, and moving the script to another machine needs no credential setup.

    Unattended jobs need defensive code. Check the exit status of curl, retry on 429 and 503 with sensible waits, and give up after a few attempts so a job never loops forever. Remember the endpoint has no SLA. If a missed report would cause real harm, add a fallback or use a provider with guarantees.

    Timeouts

    Set --max-time on every call so a slow response cannot hang a cron job. Long answers take a while, so allow enough time.

    Spread schedules

    Do not start all jobs at exactly midnight. Staggered times spread requests and stay well within one request per second.

    Code editor with a JavaScript fetch call to the API
    A scheduled job with retries and timeouts runs quietly for months.

    Retries, exit codes and the 429/503 pair

    Limits apply per IP address: one request per second with bursts of three, two in parallel, and 10,000 requests or 10,000,000 tokens per day, reset at 00:00 UTC. Over the limit the server returns 429 with a Retry-After header. When the model is busy serving others it returns 503, and the right response is to wait two to five seconds and try again.

    In shell, the simplest robust pattern is a loop. Capture the status code with -w '%{http_code}', read Retry-After with -D for headers, sleep, and retry a few times. curl's own --retry option also handles many transient errors. Keep parallel calls to two, for example with xargs -P 2, when processing many files.

    Batch work with xargs

    xargs -P 2 keeps two requests in flight; add a short sleep inside the command to respect the per-second rate.

    Fail loudly

    Use set -e and curl -f so a script stops on errors instead of writing empty answers into files.

    Diagram of a 429 error followed by retries
    Read Retry-After on 429; pause briefly on 503.

    Limits for scripts and cron jobs

    Per IP: 1 request per second (bursts of 3), 2 parallel requests, 10,000 requests or 10,000,000 tokens per day, reset at 00:00 UTC. Context 32,000 tokens, answers up to 16,000 tokens. On 429 wait for Retry-After; on 503 retry in 2-5 seconds. Text only: no images, audio or embeddings.

    requests per second
    1
    parallel requests
    2
    context, tokens
    32,000
    answer, tokens
    16,000
    requests per day
    10,000
    tokens per day
    10,000,000
    Bar chart of the per-second, parallel and daily limits of the API
    The limits at a glance
    Ring gauge showing how much of the daily request allowance is left
    Daily allowance resets at 00:00 UTC
    Diagram of a 429 error followed by retries with growing waits
    Orderly retry after a 429

    Web-UI automation and key-rotation proxies

    Two kinds of projects keep appearing for people who want free AI in scripts. One drives the consumer Gemini web page through a headless browser, so a script can use the chat with no key. The other is a proxy that rotates a pile of free API keys to stretch quotas. Both promise unlimited free use, and both carry risks that matter more for automation than for a one-off test.

    Browser automation breaks when the page changes and can violate the consumer terms, putting your Google account at risk. Key rotation across many accounts generally breaks the API terms, and rotating keys collected from the internet means spending other people's money. Exposed keys are revoked quickly, and a script built on them fails without warning.

    Agent loops and cost

    Coding agents that retry a failing build dozens of times can burn through paid credit fast. Cap iterations and set budget alerts on any paid key.

    A cleaner free option

    An endpoint built for API use and needing no key avoids both problems, at the cost of using a smaller model.

    Illustration of a document with a pen writing text
    Use APIs built for scripts rather than automating someone's web page.

    Where Gemini is worth the key

    A 35B model at no cost is great for explanations, quick commands and summaries, but it is not a frontier model. Gemini models handle much longer and harder coding tasks, reason more reliably through multi-step problems, and accept images, audio and documents, none of which free-ai supports. Google also offers paid terms and enterprise controls on Cloud.

    A good split for terminal work is to use the free endpoint for the many small, low-stakes questions you ask every day, and a paid model for the occasional large refactor or deep debugging session. Keep the base URL and model in environment variables so the same helper functions can talk to either.

    Fine for free-ai

    Command syntax, short scripts, explaining errors, summarizing logs, drafting commit messages and README sections, and translating text.

    Better on Gemini

    Multi-file refactors, long codebases, tricky reasoning, image or PDF input, and work that needs a support agreement.

    Window with a JSON response from the API
    Small questions to the free model, big jobs to a paid one.

    Gemini key in the shell vs keyless curl

    A plain comparison for command-line use. Check Google's current documentation and pricing pages for Gemini details.

    Gemini APIfree-ai on FreeKeyAPIGeminiWho wins
    SetupAI Studio key exported as a variableNothing, curl is enoughfree-ai
    Simplest callJSON POST with a key headercurl "/ask?q=..." returns textfree-ai
    CostFree tier with limits, then paidFree within per-IP daily limitsfree-ai on price
    Coding depthLarge models for long, hard tasksAbout 35B model, short tasksGemini
    Images, audio, documentsSupported on multimodal modelsText onlyGemini
    Safe in public dotfilesKey must stay privateNo secret to leakfree-ai
    RefusalsCommercial safety policiesRefuses far less, two hard rulesDepends on the task
    GuaranteesPaid terms and Cloud supportNo SLA, no support contractGemini
    Chart comparing a free service with paid plans
    Free curl calls for the many small questions; a paid model for the few big ones.

    Using OpenAI-compatible CLIs and SDKs from the terminal

    Many command-line tools and libraries accept a custom OpenAI-style base URL. Point them at https://api.freekeyapigemini.com/v1, set the model to free-ai, and give any placeholder as the key if the tool demands one. The Python and Node openai packages work the same way, which is handy for slightly bigger scripts that outgrow pure shell.

    Streaming works too: set "stream": true and the server sends events, ending with data: [DONE]. With curl, add -N to disable buffering so tokens appear as they arrive. For harder questions, add "reasoning": true and raise max_tokens to 2000 or more, since the model thinks before it answers.

    For coding assistants

    The prompt.txt file on this page describes the endpoint for a coding assistant, so it can write working client code without guessing.

    Machine-readable docs

    llms.txt gives a compact summary of endpoints and limits for tools that read it.

    Terminal with a curl command sending a question to the API
    curl -N shows streamed tokens the moment they arrive.

    Keeping secrets out of your shell history

    If you do use a Gemini key in the terminal, a few habits prevent the classic mistakes. Avoid typing keys directly into commands, because they land in shell history. Do not echo them in scripts that log output. Keep them out of dotfiles that sync to public repositories, and restrict the key in the Cloud console to the Gemini API only.

    With the keyless endpoint, these concerns disappear for the API itself, but the content you send still matters. Commands you pipe may include secrets from environment variables or config files. Make a habit of scrubbing, and treat any third-party AI service as a place where text may be logged.

    If a key leaks

    Delete or rotate it in the Cloud console right away, check billing for unusual usage, and search your repositories for other copies.

    Prefer files over flags

    Read keys from a file with tight permissions instead of passing them as command-line flags, which other users on a machine may see in the process list.

    Connected nodes forming an automated workflow
    Keys belong in protected files or vaults, never in history or dotfiles.

    What is logged when you curl

    Every request leaves a technical log entry: time, IP address, User-Agent (curl announces itself), country, endpoint, status code, latency, request and response sizes, and token counts. The IP address is used for rate limits. There are no accounts, so nothing ties a request to you beyond the IP and whatever the text itself reveals.

    The API is stateless and keeps no conversation history; your script decides what to send each time. A question sent through /ask is part of the URL, which tends to be logged in more places than a request body. Never send private keys, passwords, environment dumps or customer data. Use a provider with written data terms for sensitive work.

    Shield icon for good practice with a public service
    Good practice with a public service

    Guides and answers about free AI API usage

    Articles →