Skip to content

BatchRunners

Rasmus Wulff Jensen edited this page May 20, 2026 · 1 revision

Batch Runners

Batch runners provide helpers for OpenAI and Azure OpenAI batch jobs.

Note

Batch runner APIs are marked experimental with AFT999.

Packages

  • OpenAI: dotnet add package AgentFrameworkToolkit.OpenAI
  • Azure OpenAI: dotnet add package AgentFrameworkToolkit.AzureOpenAI

OpenAI

OpenAIBatchRunner batchRunner = new("<apiKey>");

ChatBatchRun run = await batchRunner.RunChatBatchAsync(
    new ChatBatchOptions
    {
        Model = "gpt-5-mini"
    },
    [
        ChatBatchRequest.Create("Summarize this text.")
    ]);

OpenAI batch runners support:

  • Chat batches with RunChatBatchAsync
  • Structured-output chat batches with RunChatBatchAsync<T>
  • Existing chat batch lookup with GetChatBatchAsync
  • Existing structured chat batch lookup with GetChatBatchAsync<T>
  • Embedding batches with RunEmbeddingBatchAsync
  • Existing embedding batch lookup with GetEmbeddingBatchAsync

Azure OpenAI

AzureOpenAIBatchRunner batchRunner = new("<endpoint>", "<apiKey>");

ChatBatchRun run = await batchRunner.RunChatBatchAsync(
    new ChatBatchOptions
    {
        Model = "<deployment-name>"
    },
    [
        ChatBatchRequest.Create("Summarize this text.")
    ]);

Azure OpenAI batch runners support:

  • Chat batches with RunChatBatchAsync
  • Structured-output chat batches with RunChatBatchAsync<T>
  • Existing chat batch lookup with GetChatBatchAsync
  • Existing structured chat batch lookup with GetChatBatchAsync<T>

Authentication

AzureOpenAIBatchRunner withApiKey = new("<endpoint>", "<apiKey>");
AzureOpenAIBatchRunner withRbac = new("<endpoint>", new AzureCliCredential());
OpenAIBatchRunner withConnection = new(new OpenAIConnection { ApiKey = "<apiKey>" });

Notes

  • In Azure OpenAI, Model is your deployment name.
  • Batch runners reuse the same connection objects as the corresponding provider factories.

Clone this wiki locally