-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CodeGate doesn't work with either LiteLLM or OpenRouter #878
Comments
I think how it works aldy As my litellm proxy uses os.environ/GEMINI_API_KEY for the config.yaml file, I need to pass in GEMINI's api key instead of LiteLLM master key: https://docs.litellm.ai/docs/providers/gemini Extract of sample
Here is the amendment I made for CodeGate to work: Should be working now, and I will close this issue. |
But, it seems like leading to another error, which it doesn't trigger when there are secrets inside the file: Here is the same credentials in my And when I check codegate via docker logs, and I found a lot of errors there: And not sure if it's related to the errors above, I found there are some 304 errors for my litellm proxy's UI? But, I think I didn't access my litellm proxy's UI that time.... (Not that sure) I am thinking it's better for me to try to configure it via openai API first, and then transfer to litellm API ... |
@tan-yong-sheng thanks for filing the issue! The rate limits were a codegate bug that was fixed in main but not released yet. We'll get a release out shortly. I've not used the litellm proxy myself, but I assume it works somewhat like openrouter? Sounds like you expected the litellm master key to work? If yes, it might be worth to reopen this issue and investigate. |
I see, noted on the info and thanks. Yes, litellm proxy is kinda similar to openrouter which is to unify the llm endpoints from different providers. Ya, I previously expect LITELLM_MASTER_KEY to work, but in the end, I found I need to pass the GEMINI_API_KEY here I want to Gemini llm. Also, I could pass in MISTRAL_API_KEY if I want to Mistral llm. It means LITELLM_MASTER_KEY not being used to fill in the image below, but it still works (note: perhaps this is how litellm proxy works and I would add on more info about this when I am available) |
ok, reopening for further triage. We need to make sure codegate works well without the workarounds. Thanks again for finding the bug and filing the issue. |
Hi @jhrozek, could I request any docker container (e.g., ghcr.io/stacklok/codegate:test) for testing? I am not that sure if I am doing right to build the docker image for codegate's main repository: I tried to Yet, when I use cline (even with openai endpoint: https://api.openai.com/v1), it still couldn't trigger and detect credentials. The prompt I used to reproduce the error is However, for docker logs, no error logs for codegate's docker container as before: |
I don't think you need to build a local container (unless you want to!) we release several times a month and the current release is just a couple of days old.
I think this is a configuration issue. In order for cline to talk to codegate, you should point it to codegate as the base URL, not to the LLM ![]()
I think this would be solved by pointing the extension to codegate. btw does it still stand that the main issue is not being able to use litellm through the main key? |
Just a quick note, I think I was able to reproduce your issue (and I think it was the same issue that @danbarr pinged me about some days ago). Will keep digging to fix this! |
I see, thanks a lot. I will test again when the bug (= codegate is not triggered when I ask LLM to read config.ini file to safeguard my credentials) is fixed. Thanks a lot for your efforts in delivering this product. Tbh, I am impressed with the idea of this project to safeguard credentials and filter risky dependencies when doing AI coding. |
Ya, initially I thought we can't use LiteLLM proxy with Cline and Codegate, and it keeps saying authentication error. That's the reason I create this issue. But, for now, I think it's not that much matter, as I found the workaround to solve this issue. We could use the GEMINI_API_KEY or CODESTRAL_API_KEY for respective LLM models, instead of LITELLM_MASTER_KEY. And it works! DemonstrationJust for your info, here is what I did to use Cline (together with LiteLLM proxy) with and without codegate: (1) WITHOUT codegate and with LiteLLM proxy (2) WITH codegate and with LiteLLM proxy Reply to issueI hope this explanation is clear. I believe we can maintain the existing configuration, since we have a workaround to enable Cline and Codegate to work together with LiteLLM. Therefore, I suggest closing this issue. Additional info(i) the You could ignore this, but it's for clarify for my setup to self-host LiteLLM proxy on my Linux cloud server. Here is what I setup for
Reference: https://docs.litellm.ai/docs/proxy/configs (ii) How to run codegate via docker container Note: I change CODEGATE_OPENAI_URL from https://api.openai.com/v1 to https://<MY_LITELLM_URL>/v1 docker run --name codegate -d -p 8989:8989 -p 9090:9090 -e CODEGATE_OPENAI_URL=https://<MY_LITELLM_URL>/v1 --mount type=volume,src=codegate_volume,dst=/app/codegate_volume --restart unless-stopped ghcr.io/stacklok/codegate |
Hey @tan-yong-sheng , great having you here and thanks for the time you took to explain the issues well ❤ Looping back to the secrets sensing, we would need to pattern match those tokens, you will find the matching list here and we currently match the crypto itself, not the variable name.
However are just about to rework this system to match both #209 and also look and use of entropy for matching. Would love to have you try this out when we have something in the way of a prototype? |
Ah I see, no wonder.
Interesting ideas and discussions
Yaya, should be no problem. My pleasure. Thanks as well. |
OpenRouter is a "muxing provider" which itself provides access to multiple models and providers. It speaks a dialect of the OpenAI protocol, but for our purposes, we can say it's OpenAI. There are some differences in handling the requests, though: 1) we need to know where to forward the request to, by default this is `https://openrouter.ai/api/v1`, this is done by setting the base_url parameter 2) we need to prefix the model with `openrouter/`. This is a lite-LLM-ism (see https://docs.litellm.ai/docs/providers/openrouter) which we'll be able to remove once we ditch litellm Initially I was considering just exposing the OpenAI provider on an additional route and handling the prefix based on the route, but I think having an explicit provider class is better as it allows us to handle any differences in OpenRouter dialect easily in the future. Related: #878
@tan-yong-sheng I opened a PR that fixes a very similar issue for OpenRouter. I think fixing your issue for litellm would be along the same lines. Can you suggest an easy way to test litellm proxy to simulate your environment? I found https://docs.litellm.ai/docs/proxy/deploy so I can try that - I'm familiar with using litellm as a library, but not as a proxy |
Here is the the way to start an localhost instance for litellm. But I am not that sure if this is working as I never tried localhost version one (note: not available at the moment to test this before writing).. Reference: https://thinhdanggroup.github.io/litellm-proxy/#setting-up-litellm-proxy-locally
(Note: I get Gemini API key for free in Google ai studio)
(Note 1: You could refer https://docs.litellm.ai/docs/proxy/configs for the format of config file, if you need to add more configuration)
https://docs.litellm.ai/docs/proxy/user_keys For example,
Let me know if you need further help, thanks. |
OpenRouter is a "muxing provider" which itself provides access to multiple models and providers. It speaks a dialect of the OpenAI protocol, but for our purposes, we can say it's OpenAI. There are some differences in handling the requests, though: 1) we need to know where to forward the request to, by default this is `https://openrouter.ai/api/v1`, this is done by setting the base_url parameter 2) we need to prefix the model with `openrouter/`. This is a lite-LLM-ism (see https://docs.litellm.ai/docs/providers/openrouter) which we'll be able to remove once we ditch litellm Initially I was considering just exposing the OpenAI provider on an additional route and handling the prefix based on the route, but I think having an explicit provider class is better as it allows us to handle any differences in OpenRouter dialect easily in the future. Related: #878
* Move _get_base_url to the base provider In order to properly support "muxing providers" like openrouter, we'll have to tell litellm (or in future a native implementation), what server do we want to proxy to. We were already doing that with Vllm, but since are about to do the same for OpenRouter, let's move the `_get_base_url` method to the base provider. * Add an openrouter provider OpenRouter is a "muxing provider" which itself provides access to multiple models and providers. It speaks a dialect of the OpenAI protocol, but for our purposes, we can say it's OpenAI. There are some differences in handling the requests, though: 1) we need to know where to forward the request to, by default this is `https://openrouter.ai/api/v1`, this is done by setting the base_url parameter 2) we need to prefix the model with `openrouter/`. This is a lite-LLM-ism (see https://docs.litellm.ai/docs/providers/openrouter) which we'll be able to remove once we ditch litellm Initially I was considering just exposing the OpenAI provider on an additional route and handling the prefix based on the route, but I think having an explicit provider class is better as it allows us to handle any differences in OpenRouter dialect easily in the future. Related: #878 * Add a special ProviderType for openrouter We can later alias it to openai if we decide to merge them. * Add tests for the openrouter provider * ProviderType was reversed, thanks Alejandro --------- Co-authored-by: Radoslav Dimitrov <[email protected]>
Hi, just wanna check if the method above works to use litellm proxy on localhost (in linux environment)? Let me know if you need any help. |
Thank you for the pointers. We merged the the openrouter patches last week and the litellm support should be along the same lines. I got sidetracked by other work, but I'll try to get this back on track soon! If other codegate developers want to take this issue from me, feel free to. |
hey, @tan-yong-sheng 👋 So I've tried an example setup locally and I think I was able to reproduce the issue. TLDR: The main issue is that our internal dependency on litellm (not the proxy, but the library which we are in the works of removing 🥳 ) re-routes on its own the model provider URL based on the model name. We are expecting to release a fix for this in the next 1 or 2 releases. The setup that I have is the following:
![]()
model_list:
- model_name: phi4
litellm_params:
model: ollama/phi4 # LiteLLM expects the models to be prefixed by their provider
api_base: http://localhost:11434 # This is where Ollama is serving
general_settings:
master_key: sk-1234 # That secret is used in the Cline config for API key The issue:
Solution:
I'll ping you once this is released 🙏 The work is almost complete so it should drop in some of the next releases. |
Hi, sorry for missing this and being for reply.
Sure, thanks a lot. |
I am trying to use codegate with cline, and connect LLM api via LiteLLM proxy (hosted on cloud)
Environment:
Here are the steps I did:
docker run --name codegate -d -p 8989:8989 -p 9090:9090 -e CODEGATE_OPENAI_URL=https://<MY_LITELLM_URL>/v1 --restart unless-stopped ghcr.io/stacklok/codegate
I thought as I set the environment variable to CODEGATE_OPENAI_URL=https://litellm.tanyongsheng.site/v1, it will change the default environment variable for openai url
However, I still get this error:
And when I tried to switch to gemini 2.0 that I set up in litellm proxy. There is still error coming up:
Hope for help, thanks
The text was updated successfully, but these errors were encountered: