Ugrás a fő tartalomhoz

Ezt a böngészőt már nem támogatjuk.

Frissítsen a Microsoft Edge-re, hogy kihasználhassa a legújabb funkciókat, a biztonsági frissítéseket és a technikai támogatást.

A Microsoft Edge letöltése További információk az Internet Explorerről és a Microsoft Edge-ről
microsoft-foundry.rest.security.o-auth2-auth

Batch

Create a batch

POST /openai/v1/batches

Creates a batch from the supplied request.

Kérelem törzse

The request body.

Content-Type: application/json
input_file_id string kötelező

The ID of an uploaded file that contains requests for the new batch. See upload file for how to upload a file. Your input file must be formatted as a JSONL file, and must be uploaded with the purpose batch. The file can contain up to 50,000 requests, and can be up to 200 MB in size.

endpoint enum kötelező

The endpoint to be used for all requests in the batch. Currently /v1/responses, /v1/chat/completions, /v1/embeddings, /v1/completions, /v1/moderations, /v1/images/generations, /v1/images/edits, and /v1/videos are supported. Note that /v1/embeddings batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch.

/v1/responses/v1/chat/completions/v1/embeddings/v1/completions/v1/moderations/v1/images/generations/v1/images/edits/v1/videos
completion_window enum kötelező

The time frame within which the batch should be processed. Currently only 24h is supported.

24h
metadata OpenAI.Metadata | null

Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.

[key: string] string
output_expires_after OpenAI.BatchFileExpirationAfter

The expiration policy for the output and/or error file that are generated for a batch.

anchor enum kötelező

Anchor timestamp after which the expiration policy applies. Supported anchors: created_at. Note that the anchor is the file creation time, not the time the batch is created.

created_at
seconds integer kötelező

The number of seconds after the anchor time that the file will expire. Must be between 3600 (1 hour) and 2592000 (30 days).

Válaszok

The request has succeeded.

Törzs

Content-Type: application/json
id string kötelező
object enum kötelező

The object type, which is always batch.

batch
endpoint string kötelező

The OpenAI API endpoint used by the batch.

model string

Model ID used to process the batch, like gpt-6-astra. OpenAI offers a wide range of models with different capabilities, performance characteristics, and price points. Refer to the model guide to browse and compare available models.

errors OpenAI.BatchErrors | null
object string
data OpenAI.BatchError[]
input_file_id string kötelező

The ID of the input file for the batch.

completion_window string kötelező

The time frame within which the batch should be processed.

status enum kötelező

The current status of the batch.

validatingfailedin_progressfinalizingcompletedexpiredcancellingcancelled
output_file_id string | null

The ID of the file containing the outputs of successfully executed requests.

error_file_id string | null

The ID of the file containing the outputs of requests with errors.

created_at integer kötelező

The Unix timestamp (in seconds) for when the batch was created.

in_progress_at integer | null

The Unix timestamp (in seconds) for when the batch started processing.

expires_at integer | null

The Unix timestamp (in seconds) for when the batch will expire.

finalizing_at integer | null

The Unix timestamp (in seconds) for when the batch started finalizing.

completed_at integer | null

The Unix timestamp (in seconds) for when the batch was completed.

failed_at integer | null

The Unix timestamp (in seconds) for when the batch failed.

expired_at integer | null

The Unix timestamp (in seconds) for when the batch expired.

cancelling_at integer | null

The Unix timestamp (in seconds) for when the batch started cancelling.

cancelled_at integer | null

The Unix timestamp (in seconds) for when the batch was cancelled.

request_counts OpenAI.BatchRequestCounts

The request counts for different statuses within the batch.

total integer kötelező
completed integer kötelező
failed integer kötelező
usage OpenAI.BatchUsage
input_tokens integer kötelező
input_tokens_details OpenAI.BatchUsageInputTokensDetails kötelező
cached_tokens integer kötelező
output_tokens integer kötelező
output_tokens_details OpenAI.BatchUsageOutputTokensDetails kötelező
reasoning_tokens integer kötelező
total_tokens integer kötelező
metadata OpenAI.Metadata | null

Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.

[key: string] string

Client error

Törzs

Content-Type: application/json
error OpenAI.Error kötelező
code string | null kötelező
message string kötelező
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
A következők bármelyike:
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string kötelező

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Server error

Törzs

Content-Type: application/json
error OpenAI.Error kötelező
code string | null kötelező
message string kötelező
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
A következők bármelyike:
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string kötelező

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Kérés

curl https://api.openai.com/v1/batches \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input_file_id": "file-abc123",
    "endpoint": "/v1/chat/completions",
    "completion_window": "24h"
  }'
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),  # This is the default and can be omitted
)
batch = client.batches.create(
    completion_window="24h",
    endpoint="/v1/responses",
    input_file_id="input_file_id",
)
print(batch.id)
import OpenAI from "openai";

const openai = new OpenAI();

async function main() {
  const batch = await openai.batches.create({
    input_file_id: "file-abc123",
    endpoint: "/v1/chat/completions",
    completion_window: "24h"
  });

  console.log(batch);
}

main();
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

const batch = await client.batches.create({
  completion_window: '24h',
  endpoint: '/v1/responses',
  input_file_id: 'input_file_id',
});

console.log(batch.id);
package main

import (
    "context"
    "fmt"

    "github.com/openai/openai-go"
    "github.com/openai/openai-go/option"
)

func main() {
    client := openai.NewClient(
        option.WithAPIKey("My API Key"),
    )
    batch, err := client.Batches.New(context.TODO(), openai.BatchNewParams{
        CompletionWindow: openai.BatchNewParamsCompletionWindow24h,
        Endpoint:         openai.BatchNewParamsEndpointV1Responses,
        InputFileID:      "input_file_id",
    })
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("%+v
", batch.ID)
}
package com.openai.example;

import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.batches.Batch;
import com.openai.models.batches.BatchCreateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        OpenAIClient client = OpenAIOkHttpClient.fromEnv();

        BatchCreateParams params = BatchCreateParams.builder()
            .completionWindow(BatchCreateParams.CompletionWindow._24H)
            .endpoint(BatchCreateParams.Endpoint.V1_RESPONSES)
            .inputFileId("input_file_id")
            .build();
        Batch batch = client.batches().create(params);
    }
}
require "openai"

openai = OpenAI::Client.new(api_key: "My API Key")

batch = openai.batches.create(
  completion_window: :"24h",
  endpoint: :"/v1/responses",
  input_file_id: "input_file_id"
)

puts(batch)

Válasz

{
  "id": "batch_abc123",
  "object": "batch",
  "endpoint": "/v1/chat/completions",
  "errors": null,
  "input_file_id": "file-abc123",
  "completion_window": "24h",
  "status": "validating",
  "output_file_id": null,
  "error_file_id": null,
  "created_at": 1711471533,
  "in_progress_at": null,
  "expires_at": null,
  "finalizing_at": null,
  "completed_at": null,
  "failed_at": null,
  "expired_at": null,
  "cancelling_at": null,
  "cancelled_at": null,
  "request_counts": {
    "total": 0,
    "completed": 0,
    "failed": 0
  },
  "metadata": {
    "customer_id": "user_123456789",
    "batch_description": "Nightly eval job",
  }
}
hu-hu
Az Ön adatvédelmi választási lehetőségei
  • AI-jogi nyilatkozat
  • Korábbi verziók
  • Blog
  • Közreműködés
  • Adatvédelem
  • A Consumer Health adatvédelmi nyilatkozata
  • Használati feltételek
  • Védjegyek
  • © Microsoft 2026