| page_title | openai_batch Resource - terraform-provider-openai |
|---|---|
| subcategory | |
| description | Manages an OpenAI Batch. |
Manages an OpenAI Batch.
# 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
}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.
completion_window(String) The time frame within which the batch should be processed. Currently only '24h' is supported.metadata(Map of String) Metadata.
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)
Read-Only:
data(Attributes List) (see below for nested schema)object(String)
Read-Only:
code(String)line(Number)message(String)param(String)
Read-Only:
completed(Number)failed(Number)total(Number)
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