Skip to main content

Method

Cancels a tuning job that is currently running or pending. Once cancelled, the job cannot be resumed.
string
required
The resource name of the tuning job to cancel. Format:
  • Vertex AI: projects/{project}/locations/{location}/tuningJobs/{job_id}
  • Gemini API: tunedModels/{model_id}
CancelTuningJobConfig
Optional configuration for the cancel request

Response

HttpResponse
HTTP response information including headers and status
The method returns an empty response object on success. The job state will be updated to JOB_STATE_CANCELLED.

Usage

Cancel a Tuning Job

Cancel with Error Handling

Cancel All Running Jobs

Cancel and Wait for Confirmation

Conditional Cancellation

Important Notes

Cancelling a tuning job is irreversible. The job cannot be resumed after cancellation.
  • Only jobs in RUNNING, PENDING, or QUEUED states can be cancelled
  • Jobs that are SUCCEEDED, FAILED, or already CANCELLED cannot be cancelled
  • Cancellation is asynchronous - the job state may not immediately reflect the cancellation
  • No partial models are saved when a job is cancelled
  • You will not be charged for the remaining compute time after cancellation

Error Handling

The cancel operation may fail in the following cases:
  • Job not found: The specified job name doesn’t exist
  • Invalid state: The job is already completed or cancelled
  • Permission denied: Insufficient permissions to cancel the job
  • Network error: Connection issues with the API

See Also