from google import genaiclient = genai.Client(api_key='your-api-key')# Iterate through all tuning jobsfor tuning_job in client.tunings.list(): print(f"Job: {tuning_job.name}") print(f"State: {tuning_job.state}") print(f"Created: {tuning_job.create_time}") print("---")
from google.genai import types# Get first page with 10 jobsconfig = types.ListTuningJobsConfig(page_size=10)pager = client.tunings.list(config=config)# Process first pagefirst_page = list(pager)print(f"First page has {len(first_page)} jobs")# Get next page if availableif pager.next_page_token: config.page_token = pager.next_page_token next_pager = client.tunings.list(config=config) next_page = list(next_pager) print(f"Next page has {len(next_page)} jobs")
from google.genai import types# List only successful tuning jobsconfig = types.ListTuningJobsConfig( filter='state=JOB_STATE_SUCCEEDED')for tuning_job in client.tunings.list(config=config): print(f"Completed job: {tuning_job.name}") print(f"Model: {tuning_job.tuned_model.model}")
from datetime import datetime, timedeltafrom google.genai import types# Get jobs from the last 7 daysweek_ago = datetime.now() - timedelta(days=7)recent_jobs = []for tuning_job in client.tunings.list(): job_time = datetime.fromisoformat(tuning_job.create_time.replace('Z', '+00:00')) if job_time > week_ago: recent_jobs.append(tuning_job)print(f"Found {len(recent_jobs)} jobs in the last week")