Skip to main content

Method

client.tunings.list(
    config: Optional[ListTuningJobsConfig] = None
) -> Pager[TuningJob]
Returns a paginated list of all tuning jobs in your project. The pager automatically handles pagination when iterating.
config
ListTuningJobsConfig
Configuration options for the list request

Response

Returns a Pager[TuningJob] object that implements the iterator protocol. Each iteration yields a TuningJob object.
TuningJob
object
Each tuning job in the list contains:

Usage

List All Tuning Jobs

from google import genai

client = genai.Client(api_key='your-api-key')

# Iterate through all tuning jobs
for 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("---")

With Pagination Control

from google.genai import types

# Get first page with 10 jobs
config = types.ListTuningJobsConfig(page_size=10)
pager = client.tunings.list(config=config)

# Process first page
first_page = list(pager)
print(f"First page has {len(first_page)} jobs")

# Get next page if available
if 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")

Filter by State (Vertex AI)

from google.genai import types

# List only successful tuning jobs
config = 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}")

Find Recent Jobs

from datetime import datetime, timedelta
from google.genai import types

# Get jobs from the last 7 days
week_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")

Monitor Running Jobs

from google.genai import types

# Find all running or pending jobs
running_states = [
    types.JobState.JOB_STATE_RUNNING,
    types.JobState.JOB_STATE_PENDING,
    types.JobState.JOB_STATE_QUEUED
]

running_jobs = []
for tuning_job in client.tunings.list():
    if tuning_job.state in running_states:
        running_jobs.append(tuning_job)
        print(f"Active job: {tuning_job.name}")
        print(f"State: {tuning_job.state}")
        print(f"Started: {tuning_job.start_time}")
        print("---")

print(f"\nTotal active jobs: {len(running_jobs)}")

Export Job List

import json

# Collect all tuning jobs
jobs_data = []
for tuning_job in client.tunings.list():
    jobs_data.append({
        'name': tuning_job.name,
        'state': tuning_job.state,
        'base_model': tuning_job.base_model,
        'create_time': tuning_job.create_time,
        'tuned_model': tuning_job.tuned_model.model if tuning_job.tuned_model else None
    })

# Save to file
with open('tuning_jobs.json', 'w') as f:
    json.dump(jobs_data, f, indent=2)

print(f"Exported {len(jobs_data)} tuning jobs")

Notes

  • The pager automatically fetches additional pages as you iterate
  • Page size defaults vary between Gemini API and Vertex AI
  • Filtering is only supported on Vertex AI
  • Jobs are returned in reverse chronological order (newest first)

See Also

Build docs developers (and LLMs) love