Skip to content

Latest commit

 

History

History
115 lines (85 loc) · 2.7 KB

File metadata and controls

115 lines (85 loc) · 2.7 KB
page_title openai_batch Resource - terraform-provider-openai
subcategory
description Manages an OpenAI Batch.

openai_batch (Resource)

Manages an OpenAI Batch.

Example Usage

# Create a file with batch requests for chat completions
resource "openai_file" "batch_input" {
  file    = "${path.module}/batch_requests.jsonl"
  purpose = "batch"
}

# Create a batch job to process multiple chat completion requests
resource "openai_batch" "chat_completions" {
  input_file_id = openai_file.batch_input.id
  endpoint      = "/v1/chat/completions"

  # Optional: Set completion window (default is 24h)
  completion_window = "24h"

  # Optional: Add metadata for tracking
  metadata = {
    department = "customer-support"
    batch_type = "daily-analysis"
    version    = "1.0"
  }
}

# Output the batch ID
output "batch_id" {
  value = openai_batch.chat_completions.id
}

Schema

Required

  • endpoint (String) The endpoint to use for the batch request (e.g., '/v1/chat/completions').
  • input_file_id (String) The ID of the input file.

Optional

  • completion_window (String) The time frame within which the batch should be processed. Currently only '24h' is supported.
  • metadata (Map of String) Metadata.

Read-Only

  • cancelled_at (Number)
  • cancelling_at (Number)
  • completed_at (Number)
  • created_at (Number)
  • error (String) ID of the error file (legacy field naming).
  • error_file_id (String)
  • errors (Attributes) (see below for nested schema)
  • expired_at (Number)
  • expires_at (Number)
  • failed_at (Number)
  • finalizing_at (Number)
  • id (String) The identifier of the batch.
  • in_progress_at (Number)
  • output_file_id (String)
  • request_counts (Attributes) (see below for nested schema)
  • status (String)

Nested Schema for errors

Read-Only:

Nested Schema for errors.data

Read-Only:

  • code (String)
  • line (Number)
  • message (String)
  • param (String)

Nested Schema for request_counts

Read-Only:

  • completed (Number)
  • failed (Number)
  • total (Number)

Import

Import is supported using the following syntax:

The terraform import command can be used, for example:

#!/bin/bash
# Import existing OpenAI batch
terraform import openai_batch.example batch_abc123def456