Skip to content

Allow using Gemini CLI for free Gemini requests #402

Closed as not planned
Closed as not planned

Description

@skyfallwastaken

I'm going to apologise in advance if this is a unreasonable request, but Gemini CLI has a very generous free tier and it would be quite nice to route Gemini requests through it (especially since it costs Google the same amount of money anyway)

Activity

  1. BasixKOR commented on Jun 25, 2025

    @BasixKOR
  2. self-assigned this
    on Jun 25, 2025
  3. thdxr commented on Jun 25, 2025

    @thdxr
    Member

    this would honestly be a great PR it might fit in very nicely into how claude pro/max is implemented

  4. sockthedev commented on Jun 26, 2025

    @sockthedev

    one tui to rule them all...

  5. izyuumi commented on Jun 26, 2025

    @izyuumi

    Does something like this work?

  6. aryasaatvik commented on Jun 26, 2025

    @aryasaatvik
    Contributor

    got it working with with custom ai sdk provider. here is my config ~/.config/opencode.json.

    this needs you to use gemini cli to login initially

    https://gist.github.com/aryasaatvik/4eb60e53290b4d483bd1fe40dae6fc48

  7. fer-ri commented on Aug 3, 2025

    @fer-ri

    any update? I open gist from @aryasaatvik but seems not working anymore too.

  8. hrstoyanov commented on Aug 8, 2025

    @hrstoyanov

    With Qwen Coder CLI now out, this is becoming very interesting:

    • Gemini CLI and Qwen CLI are very similar (Qwen CLI is fork of the Gemini cli code)
    • Both provide very generous daily limits of free requests! They are practically free for individuals ....
    • Both use OAuth for the free personal access, not tokens.

    I suspect more (Chineses) AI labs will clone Gemini CLI and couple it with OAuth + generaous free daily usage quota.

    That is an opportunity for OpenCode to rule them all, @thdxr

  9. frap129 commented on Sep 24, 2025

    @frap129

    In case anyone else is also trying to get this working, I was able to do it using https://github.com/router-for-me/CLIProxyAPI.

    I configured it per the README on that project, and set up the provider in opencode. The only quirk is that I was getting invalid JSON errors when setting it up as an OpenAI compatible provider, it needed to be configured as a google provider:

      "provider": {
        "cli-proxy-api-google": {
          "npm": "@ai-sdk/google",
          "name": "CLIProxyAPI (Google)",
          "options": {
            "baseURL": "http://localhost:8317/v1beta",
            "apiKey": "<key you set in the CLIProxyAPI config>"
          },
          "models": {
            "gemini-2.5-pro": {
              "name": "Gemini 2.5 Pro"
            },
            "gemini-2.5-flash": {
              "name": "Gemini 2.5 Flash"
            },
            "gemini-2.5-flash-lite": {
              "name": "Gemini 2.5 Flash Lite"
            }
          }
        }
      }
    

    Hope this helps

  10. fer-ri commented on Sep 24, 2025

    @fer-ri

    In case anyone else is also trying to get this working, I was able to do it using https://github.com/router-for-me/CLIProxyAPI.

    I configured it per the README on that project, and set up the provider in opencode. The only quirk is that I was getting invalid JSON errors when setting it up as an OpenAI compatible provider, it needed to be configured as a google provider:

      "provider": {
        "cli-proxy-api-google": {
          "npm": "@ai-sdk/google",
          "name": "CLIProxyAPI (Google)",
          "options": {
            "baseURL": "http://localhost:8317/v1beta",
            "apiKey": "<key you set in the CLIProxyAPI config>"
          },
          "models": {
            "gemini-2.5-pro": {
              "name": "Gemini 2.5 Pro"
            },
            "gemini-2.5-flash": {
              "name": "Gemini 2.5 Flash"
            },
            "gemini-2.5-flash-lite": {
              "name": "Gemini 2.5 Flash Lite"
            }
          }
        }
      }
    

    Hope this helps

    Thanks a lot

  11. hrstoyanov commented on Sep 24, 2025

    @hrstoyanov

    So CLIProxyAPI doesn't not use OAuth, you need to provide API key?

  12. frap129 commented on Sep 24, 2025

    @frap129

    @hrstoyanov It uses oauth. The API key in the opencode config is for connecting to the local CLIProxyAPI server.

  13. nitish-raj commented on Sep 27, 2025

    @nitish-raj

    @frap129 is this still working for you? For me it doesn't seem to connect. Could you share your config file rom CLIProxyAPI?

  14. frap129 commented on Sep 27, 2025

    @frap129

    @nitish-raj Yeah, sometimes messages hang and I have to abort and resend, but otherwise it works well. My config is just the example from the CLIProxyAPI readme, with different local keys, a different auth directory, and no API keys added:

    # Server port
    port: 8317
    # Management API settings
    remote-management:
      # Whether to allow remote (non-localhost) management access.
      # When false, only localhost can access management endpoints (a key is still required).
      allow-remote: false
      # Management key. If a plaintext value is provided here, it will be hashed on startup.
      # All management requests (even from localhost) require this key.
      # Leave empty to disable the Management API entirely (404 for all /v0/management routes).
      secret-key: "REDACTED"
    # Authentication directory (supports ~ for home directory)
    auth-dir: "~/.cache/cli-proxy-api"
    # Enable debug logging
    debug: true
    # Proxy URL. Supports socks5/http/https protocols. Example: socks5://user:pass@192.168.1.1:1080/
    proxy-url: ""
    # Number of times to retry a request. Retries will occur if the HTTP response code is 403, 408, 500, 502, 503, or 504.
    request-retry: 3
    # Quota exceeded behavior
    quota-exceeded:
      switch-project: true # Whether to automatically switch to another project when a quota is exceeded
      switch-preview-model: true # Whether to automatically switch to a preview model when a quota is exceeded
    # API keys for authentication
    api-keys:
      - "REDACTED"
    
  15. JunarisAlf commented on Oct 1, 2025

    @JunarisAlf

    @frap129 very nice, the openAI compatible is work well on kilo code, but i'm wondering why is not on opencode

  16. ydevx commented on Oct 6, 2025

    @ydevx

    I successfully installed gemini api key with cliproxyapi,

    """
    CLIProxyAPI Version: dev, Commit: none, BuiltAt: unknown
    API server started successfully
    server clients and configuration updated: 11 clients (2 auth files + 4 GL API keys + 2 Claude API keys + 1 Codex keys + 2 OpenAI-compat)
    """

    but in opencode, I tried call gemini,

    Generating...
    Build gemini-2.5-flash (04:21 PM)

    then nothing shows up. Stack forever

  17. rekram1-node commented on Oct 6, 2025

    @rekram1-node
    Contributor

    @ygit1 unfamiliar with it, could you try doing:

    opencode run hello --print-logs

    and show output?

    is the proxy gemini api compliant or does it do openai compatible?

  18. luckycold commented on Oct 24, 2025

    @luckycold

    Someone just quietly made this apparently:
    https://github.com/shantur/opencode-gemini-auth

  19. jenslys commented on Nov 1, 2025

    @jenslys

    I have also created a plugin for this https://github.com/jenslys/opencode-gemini-auth

  20. Jonathan-Garcia1 commented on Nov 9, 2025

    @Jonathan-Garcia1
  21. olafgeibig commented on Nov 16, 2025

    @olafgeibig

    Very cool. I was just searching for that to prepare for the launch of Gemini 3 next week. Google has actually 1500 requests per day included with the $20 Google AI Pro subscription.

    https://developers.google.com/gemini-code-assist/resources/quotas

  22. ben-vargas commented on Nov 20, 2025

    @ben-vargas
    Contributor

    I've submitted a PR to @jenslys plugin repo to add better retry handling for the tight rate limits Gemini 3 Pro has right now. That should make it work better for everyone.

  23. iamhenry commented on Nov 20, 2025

    @iamhenry

    @olafgeibig unfortunately Pro sub cant access G3 yet. Only Ultra

  24. bitnom commented on Nov 21, 2025

    @bitnom

    @olafgeibig unfortunately Pro sub cant access G3 yet. Only Ultra

    I think you just got it on pro

  25. iamhenry commented on Nov 24, 2025

    @iamhenry

    @bitnom it's avaliable for Pro plan users?

  26. thdxr commented on Mar 25, 2026

    @thdxr
    Member

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

  27. added a commit that references this issue on May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions