gpt-3.5-turbo-0125· OpenAI
WildChat-4.8M (AI2)
I am using a jupyter notebook. write my python script to connect to gemini api using the…
- User
I am using a jupyter notebook. write my python script to connect to gemini api using the python sdk. i am using service_account and getting my credentials from service account file. once i am connected to the sdk, i need a script to query the available models
- Assistant
Here is an example Python script to connect to Gemini API using the Python SDK and query the available models:
from geminipy import Client import json # Load service account credentials from a file with open('service_account.json') as f: service_account_credentials = json.load(f) # Connect to Gemini API using service account credentials client = Client(service_account_credentials["apikey"], service_account_credentials["apisecret"]) # Get available models models = client.models.list() print("Available models:") for model in models: print(model)Make sure to replace
'service_account.json'with the path to your service account credentials file. This script will connect to Gemini API using the provided service account API key and secret, and then list the available models.