| external help file | PSOpenAI-help.xml |
|---|---|
| Module Name | PsopenAI |
| online version | https://github.com/mkht/PSOpenAI/blob/main/Docs/Start-Batch.md |
| schema | 2.0.0 |
Creates and executes a batch from an uploaded file or input objects.
Start-Batch
-BatchInput <Object[]>
[-Endpoint <String>]
[-CompletionWindow <String>]
[-OutputExpiresAfterSeconds <Int32>]
[-OutputExpiresAfterAnchor <String>]
[-MetaData <IDictionary>]
[-TimeoutSec <Int32>]
[-MaxRetryCount <Int32>]
[-ApiBase <Uri>]
[-ApiKey <SecureString>]
[-Organization <String>]
[<CommonParameters>]
Start-Batch
-FileId <String>
[-Endpoint <String>]
[-CompletionWindow <String>]
[-OutputExpiresAfterSeconds <Int32>]
[-OutputExpiresAfterAnchor <String>]
[-MetaData <IDictionary>]
[-TimeoutSec <Int32>]
[-MaxRetryCount <Int32>]
[-ApiBase <Uri>]
[-ApiKey <SecureString>]
[-Organization <String>]
[<CommonParameters>]
Creates and executes a batch from an uploaded file or input objects.
PS C:\> Start-Batch -FileId 'file-abc123'Creates and executes a batch from an uploaded file. You need to upload formatted jsonl file to the OpenAI storage in advance.
PS C:\> $BatchInputs = @()
PS C:\> $BatchInputs += Request-ChatCompletion -Message 'Good morning.' -Model gpt-4o-mini -AsBatch -CustomBatchId 'custom-1'
PS C:\> $BatchInputs += Request-ChatCompletion -Message 'Good night.' -Model gpt-4o-mini -AsBatch -CustomBatchId 'custom-2'
PS C:\> Start-Batch -InputObject $BatchInputsCreates and executes a batch from input items.
You can create a batch input item by using the Request-ChatCompletion cmdlet with -AsBatch switch.
Specifies batch input objects.
Type: Object[]
Parameter Sets: BatchObject
Required: True
Position: 0
Accept pipeline input: True (ByValue, ByPropertyName)Specifies a input file id that is uploaded on the OpenAI storage in advance.
Type: String
Parameter Sets: FileId
Aliases: input_file_id
Required: True
Position: 0
Accept pipeline input: True (ByValue, ByPropertyName)The time frame within which the batch should be processed. Currently only "24h" is supported.
Type: String
Aliases: completion_window
Required: False
Position: Named
Default value: 24hThe endpoint to be used for all requests in the batch. Currently "/v1/chat/completions", "/v1/embeddings", and "/v1/completions" are supported.
Type: String
Required: False
Position: Named
Default value: /v1/chat/completionsThe number of seconds after the anchor time that the file will expire. Must be between 3600 (1 hour) and 2592000 (30 days).
Type: Int32
Required: False
Position: NamedAnchor timestamp after which the expiration policy applies. Supported anchors: created_at.
Type: String
Required: False
Position: NamedSet 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.
Type: IDictionary
Required: False
Position: NamedSpecifies how long the request can be pending before it times out.
The default value is 0 (infinite).
Type: Int32
Required: False
Position: Named
Default value: 0Number between 0 and 100.
Specifies the maximum number of retries if the request fails.
The default value is 0 (No retry).
Note : Retries will only be performed if the request fails with a 429 (Rate limit reached) or 5xx (Server side errors) error. Other errors (e.g., authentication failure) will not be performed.
Type: Int32
Required: False
Position: Named
Default value: 0Specifies an API endpoint URL such like: https://your-api-endpoint.test/v1
If not specified, it will use https://api.openai.com/v1
Type: System.Uri
Required: False
Position: Named
Default value: https://api.openai.com/v1Specifies API key for authentication.
The type of data should [string] or [securestring].
If not specified, it will try to use $global:OPENAI_API_KEY or $env:OPENAI_API_KEY
Type: Object
Parameter Sets: (All)
Required: False
Position: NamedSpecifies Organization ID which used for an API request.
If not specified, it will try to use $global:OPENAI_ORGANIZATION or $env:OPENAI_ORGANIZATION
Type: string
Aliases: OrgId
Required: False
Position: NamedThis cmdlet will upload Batch input items to the OpenAI storage as a JSONL file implicitly.
https://developers.openai.com/api/reference/resources/batches/methods/create/