New Feature: Python — provider-independent batch request API for model services (encode/create/status/cancel/collect)

Open
#14,746 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python

Research direction

Read the proposed batch API scope and compare the referenced pydantic-ai batch codec with Semantic Kernel’s Python connector structure; the issue does not name specific SK Python files. Start by discussing the API design with maintainers, as the contribution policy requires agreement before implementation. Done means an agreed design, then a provider implementation with tests for credential grouping, polling, errors, and large embedding batches.

Written by the indexing model from the issue text.

Description

.NET python triage

Semantic Kernel currently invokes one AI service per call via service IDs, and large-input workloads are handled ad hoc inside connectors (e.g. the 100-input Gemini embedding chunking in PR #14700). Peer framework pydantic-ai provides a shared batch model: encode requests, group them by credential, create/status/cancel provider batch jobs, and report per-request results including unrun requests.

Proposal: add an opt-in batch request API for SK Python connectors (BatchRequest/Batch/result types plus batch_encode/create/status/cancel on a model-service interface), implemented first for one provider, so future connectors get consistent grouping, polling and error behavior. No public signatures change for existing non-batch paths; this needs design agreement before implementation per the contribution policy.

Users

SK users indexing document sets or running large offline evaluation/scoring workloads who today must chunk inputs and poll provider batch jobs themselves, per connector.

Expected Effect

A shared batch abstraction lets connectors (OpenAI, Azure OpenAI, Google, Anthropic) support provider batch endpoints with consistent grouping, polling and error semantics instead of ad-hoc per-connector chunking like PR #14700.

Scope

Python first (where connector activity is concentrated): a new batch module under semantic_kernel/connectors or services plus opt-in implementation on one connector (e.g. OpenAI chat or Google embeddings). .NET parity and additional providers stay out of scope until the design is agreed.

Validation

cd python && uv run pytest tests/unit/connectors -q plus new tests: encode produces provider payloads; create groups only same-credential requests; status polling stops at ended; unrun/canceled requests surface typed errors; >100-input embedding calls split like #14700. Expected: new tests fail on base, pass with change.

Risks

New public API surface in a compatibility-bound project; provider batch semantics differ (Google inline vs OpenAI file-based jobs), so a wrong abstraction could force breaking changes later.

Effort

Design discussion plus ~1-2 weeks: shared batch types and codec-equivalent helpers, one connector implementation, unit tests mirroring pydantic-ai's grouped/polling/error coverage.

Comparison

pydantic-ai implements this as provider-independent codecs shared by anthropic/_batch.py, _openai_batch.py and _google_batch.py with BatchJobError, group isolation by credential hash and byte-limit prechecks; SK has only ordered service selection (MultipleModelTests) and per-connector workarounds.

Maintainer direction requested before implementation.

AI-assisted contribution.

Dominant language
C#
Stars
28.8k
Forks
4.9k
Avg merge
2d 17h
Merged PRs (30d)
48

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/semantic-kernel

All issues in microsoft/semantic-kernel

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.