BerriAI / litellm

Python SDK, Proxy Server (LLM Gateway) to call 100+ LLM APIs in OpenAI format - [Bedrock, Azure, OpenAI, VertexAI, Cohere, Anthropic, Sagemaker, HuggingFace, Replicate, Groq]
https://docs.litellm.ai/docs/
Other
14.55k stars 1.71k forks source link

gemini don't connect #3356

Closed danilo26 closed 7 months ago

danilo26 commented 7 months ago

i have thi error when connect gemini

Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.

19:26:32 - opendevin:ERROR: llm.py:64 - 400 API key not valid. Please pass a valid API key. [reason: "API_KEY_INVALID" domain: "googleapis.com" metadata { key: "service" value: "generativelanguage.googleapis.com" } ]. Attempt #1 | You can customize these settings in the configuration.

Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.

19:26:33 - opendevin:ERROR: llm.py:64 - 400 API key not valid. Please pass a valid API key. [reason: "API_KEY_INVALID" domain: "googleapis.com" metadata { key: "service" value: "generativelanguage.googleapis.com" } ]. Attempt #2 | You can customize these settings in the configuration.

Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.

19:26:36 - opendevin:ERROR: llm.py:64 - 400 API key not valid. Please pass a valid API key. [reason: "API_KEY_INVALID" domain: "googleapis.com" metadata { key: "service" value: "generativelanguage.googleapis.com" } ]. Attempt #3 | You can customize these settings in the configuration.

Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.

19:26:41 - opendevin:ERROR: llm.py:64 - 400 API key not valid. Please pass a valid API key. [reason: "API_KEY_INVALID" domain: "googleapis.com" metadata { key: "service" value: "generativelanguage.googleapis.com" } ]. Attempt #4 | You can customize these settings in the configuration.

Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.

19:26:43 - opendevin:ERROR: llm.py:64 - 400 API key not valid. Please pass a valid API key. [reason: "API_KEY_INVALID" domain: "googleapis.com" metadata { key: "service" value: "generativelanguage.googleapis.com" } ]. Attempt #5 | You can customize these settings in the configuration. 19:26:43 - opendevin:ERROR: agent_controller.py:103 - Error in loop Traceback (most recent call last): File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/litellm/llms/gemini.py", line 239, in completion response = _model.generate_content(params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/google/generativeai/generative_models.py", line 262, in generate_content response = self._client.generate_content( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/google/ai/generativelanguage_v1beta/services/generative_service/client.py", line 791, in generate_content response = rpc( ^^^^ File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/google/api_core/gapic_v1/method.py", line 131, in call return wrapped_func(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/google/api_core/retry/retry_unary.py", line 293, in retry_wrapped_func return retry_target( ^^^^^^^^^^^^^ File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/google/api_core/retry/retry_unary.py", line 153, in retry_target _retry_error_helper( File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/google/api_core/retry/retry_base.py", line 212, in _retry_error_helper raise final_exc from source_exc File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/google/api_core/retry/retry_unary.py", line 144, in retry_target result = target() ^^^^^^^^ File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/google/api_core/timeout.py", line 120, in func_with_timeout return func(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/google/api_core/grpc_helpers.py", line 78, in error_remapped_callable raise exceptions.from_grpc_error(exc) from exc google.api_core.exceptions.InvalidArgument: 400 API key not valid. Please pass a valid API key. [reason: "API_KEY_INVALID" domain: "googleapis.com" metadata { key: "service" value: "generativelanguage.googleapis.com" } ]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/litellm/main.py", line 1644, in completion model_response = gemini.completion( ^^^^^^^^^^^^^^^^^^ File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/litellm/llms/gemini.py", line 241, in completion raise GeminiError( litellm.llms.gemini.GeminiError: 400 API key not valid. Please pass a valid API key. [reason: "API_KEY_INVALID" domain: "googleapis.com" metadata { key: "service" value: "generativelanguage.googleapis.com" } ]

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/naladog/OpenDevin/opendevin/controller/agent_controller.py", line 99, in _run finished = await self.step(i) ^^^^^^^^^^^^^^^^^^ File "/home/naladog/OpenDevin/opendevin/controller/agent_controller.py", line 212, in step action = self.agent.step(self.state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/naladog/OpenDevin/agenthub/monologue_agent/agent.py", line 236, in step resp = self.llm.completion(messages=messages) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/tenacity/init.py", line 289, in wrapped_f return self(f, *args, kw) ^^^^^^^^^^^^^^^^^^^^ File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/tenacity/init.py", line 379, in call do = self.iter(retry_state=retry_state) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/tenacity/init.py", line 325, in iter raise retry_exc.reraise() ^^^^^^^^^^^^^^^^^^^ File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/tenacity/init.py", line 158, in reraise raise self.last_attempt.result() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/concurrent/futures/_base.py", line 449, in result return self.get_result() ^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/concurrent/futures/_base.py", line 401, in get_result raise self._exception File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/tenacity/init.py", line 382, in call result = fn(*args, *kwargs) ^^^^^^^^^^^^^^^^^^^ File "/home/naladog/OpenDevin/opendevin/llm/llm.py", line 79, in wrapper resp = completion_unwrapped(args, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/litellm/utils.py", line 3077, in wrapper raise e File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/litellm/utils.py", line 2975, in wrapper result = original_function(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/litellm/main.py", line 2148, in completion raise exception_type( ^^^^^^^^^^^^^^^ File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/litellm/utils.py", line 8823, in exception_type raise e File "/home/naladog/.cache/pypoetry/virtualenvs/opendevin-gp-JtEgx-py3.11/lib/python3.11/site-packages/litellm/utils.py", line 8791, in exception_type raise APIConnectionError( litellm.exceptions.APIConnectionError: 400 API key not valid. Please pass a valid API key. [reason: "API_KEY_INVALID" domain: "googleapis.com" metadata { key: "service" value: "generativelanguage.googleapis.com" } ]

danilo26 commented 7 months ago

LLM_MODEL="gemini/gemini-1.5-pro" LLM_API_KEY="AIzaSyCWxxxxxxxxxxxxxxxxxxxxxxNRl8BAY" LLM_BASE_URL="https://generativelanguage.googleapis.com/v1beta2" LLM_EMBEDDING_MODEL="openai" WORKSPACE_BASE="./workspace"

i have this config.toml

krrishdholakia commented 7 months ago

raise GeminiError( litellm.llms.gemini.GeminiError: 400 API key not valid. Please pass a valid API key. [reason: "API_KEY_INVALID" domain: "googleapis.com" metadata { key: "service" value: "generativelanguage.googleapis.com" }

This error is coming from gemini. Your api key seems invalid.

danilo26 commented 7 months ago

Is the key generate about google