Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Getting "_InactiveRpcError" Error for list_model in google-generativeai

Code used:

 

import google.generativeai as google_genai

google_genai.configure(api_key=os.getenv('GOOGLE_API_KEY'))

for m in google_genai.list_models():
    print(m.name)

 

 Error:

 

_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
	status = StatusCode.UNAVAILABLE
	details = "failed to connect to all addresses; last error: UNKNOWN: ipv6:%5B2404:6800:4009:81e::200a%5D:443: Network is unreachable"
	debug_error_string = "UNKNOWN:Error received from peer  {grpc_message:"failed to connect to all addresses; last error: UNKNOWN: ipv6:%5B2404:6800:4009:81e::200a%5D:443: Network is unreachable", grpc_status:14, created_time:"2024-02-29T21:19:29.044540098+05:30"}"
>

 

The curl command works but the python code doesn't.

 

curl "https://generativelanguage.googleapis.com/v1beta/models?key="$API_KEY

 

 How to solve this issue?

1 REPLY 1