Gemini.Types.BatchJob (GeminiEx v0.8.2)
View SourceType definitions for batch processing jobs.
Batch processing allows submitting large numbers of requests at once with 50% cost savings compared to interactive API calls.
Batch Job States
:job_state_unspecified- Initial/unknown state:queued- Job is queued for processing:pending- Job is preparing to run:running- Job is actively processing:succeeded- Job completed successfully:failed- Job failed:cancelling- Job is being cancelled:cancelled- Job was cancelled:paused- Job is paused (Vertex AI):expired- Job expired:partially_succeeded- Some requests succeeded, some failed
Example
# Create a batch job
{:ok, batch} = Gemini.APIs.Batches.create(
"gemini-2.0-flash",
file_name: "files/input-12345"
)
# Poll for completion
{:ok, completed} = Gemini.APIs.Batches.wait(batch.name)
# Get results
if BatchJob.succeeded?(completed) do
IO.puts("Processed #{completed.completion_stats.total_count} requests")
end
Summary
Types
Batch job destination configuration.
Batch job source configuration.
Completion statistics for a batch job.
Batch job error details.
Batch job state enumeration.
Represents a batch processing job.
Functions
Checks if the batch job was cancelled.
Checks if the batch job is complete (terminal state).
Checks if the batch job failed.
Creates a BatchJob from API response.
Extracts the batch ID from the full name.
Gets the completion percentage if available.
Parses API state string to atom.
Checks if the batch job is still running.
Converts job state atom to API string format.
Checks if the batch job succeeded.
Types
@type batch_destination() :: %{ optional(:file_name) => String.t(), optional(:gcs_uri) => String.t(), optional(:bigquery_uri) => String.t(), optional(:format) => String.t(), optional(:inlined_responses) => [map()] }
Batch job destination configuration.
@type batch_source() :: %{ optional(:file_name) => String.t(), optional(:gcs_uri) => [String.t()], optional(:bigquery_uri) => String.t(), optional(:format) => String.t(), optional(:inlined_requests) => [map()] }
Batch job source configuration.
@type completion_stats() :: %{ optional(:total_count) => integer(), optional(:success_count) => integer(), optional(:failure_count) => integer() }
Completion statistics for a batch job.
@type job_error() :: %{ optional(:code) => integer(), optional(:message) => String.t(), optional(:details) => [String.t()] }
Batch job error details.
@type job_state() ::
:job_state_unspecified
| :queued
| :pending
| :running
| :succeeded
| :failed
| :cancelling
| :cancelled
| :paused
| :expired
| :partially_succeeded
Batch job state enumeration.
@type t() :: %Gemini.Types.BatchJob{ completion_stats: completion_stats() | nil, create_time: String.t() | nil, dest: batch_destination() | nil, display_name: String.t() | nil, end_time: String.t() | nil, error: job_error() | nil, model: String.t() | nil, name: String.t() | nil, src: batch_source() | nil, start_time: String.t() | nil, state: job_state() | nil, update_time: String.t() | nil }
Represents a batch processing job.
Fields
name- Resource name (e.g., "batches/abc123" for Gemini, "batchPredictionJobs/123" for Vertex)display_name- Human-readable namestate- Current job statemodel- Model used for processingsrc- Input source configurationdest- Output destination configurationcreate_time- When the job was createdstart_time- When the job started runningend_time- When the job completedupdate_time- Last update timestamperror- Error details if failedcompletion_stats- Processing statistics
Functions
Checks if the batch job was cancelled.
Checks if the batch job is complete (terminal state).
Checks if the batch job failed.
Creates a BatchJob from API response.
Handles both Gemini API and Vertex AI response formats.
Extracts the batch ID from the full name.
Gets the completion percentage if available.
Parses API state string to atom.
Checks if the batch job is still running.
Converts job state atom to API string format.
Checks if the batch job succeeded.