Skip to content

feat(messages)!: add Anthropic Message Batches API#5577

Open
cdoern wants to merge 1 commit intoogx-ai:mainfrom
cdoern:feat/messages-batches-api
Open

feat(messages)!: add Anthropic Message Batches API#5577
cdoern wants to merge 1 commit intoogx-ai:mainfrom
cdoern:feat/messages-batches-api

Conversation

@cdoern
Copy link
Copy Markdown
Collaborator

@cdoern cdoern commented Apr 16, 2026

Summary

Adds all 5 Anthropic Message Batches API endpoints under /v1/messages:

  • POST /v1/messages/batches — create a batch of message requests
  • GET /v1/messages/batches — list batches with pagination
  • GET /v1/messages/batches/{id} — retrieve batch status
  • POST /v1/messages/batches/{id}/cancel — cancel an in-progress batch
  • GET /v1/messages/batches/{id}/results — stream results as JSONL

The implementation follows the same architecture as the existing OpenAI Batches provider: KVStore persistence, background asyncio tasks with semaphore-based concurrency control, and reuse of the existing create_message() flow for processing individual batch requests.

Breaking change

MessagesConfig now requires a kvstore backend (KVStoreReference). Existing distributions are updated via codegen; out-of-tree configs will need to add this field.

Test plan

  • Integration tests added at tests/integration/messages/test_message_batches.py covering create / retrieve / list / cancel / results / duplicate-custom_id / 404, running under the messages-openai suite (already wired into tests/integration/ci_matrix.json)
  • Recordings committed against openai/gpt-4o so replay-mode CI works without an API key
  • Pre-commit checks pass (ruff, mypy, API spec, Anthropic coverage)
  • Unit tests pass
  • OpenAPI spec auto-regenerated with new endpoints
  • Distribution configs (ci-tests, starter) updated via codegen

Locally verified:

./scripts/integration-tests.sh \
  --stack-config server:ci-tests --setup gpt \
  --file tests/integration/messages/test_message_batches.py
# 6 passed in 1.76s

🤖 Generated with Claude Code

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 16, 2026

✱ Stainless preview builds

This PR will update the llama-stack-client SDKs with the following commit message.

feat(messages): add Anthropic Message Batches API

Edit this comment to update it. It will appear in the SDK's changelogs.

llama-stack-client-go studio · conflict

Your SDK build had at least one new note diagnostic, which is a regression from the base state.

New diagnostics (5 note)
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `get /v1/messages/batches`
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `post /v1/messages/batches`
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `get /v1/messages/batches/{message_batch_id}`
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `post /v1/messages/batches/{message_batch_id}/cancel`
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `get /v1/messages/batches/{message_batch_id}/results`
llama-stack-client-node studio · conflict

Your SDK build had at least one new note diagnostic, which is a regression from the base state.

New diagnostics (5 note)
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `get /v1/messages/batches`
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `post /v1/messages/batches`
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `get /v1/messages/batches/{message_batch_id}`
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `post /v1/messages/batches/{message_batch_id}/cancel`
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `get /v1/messages/batches/{message_batch_id}/results`
llama-stack-client-python studio · conflict

Your SDK build had at least one new note diagnostic, which is a regression from the base state.

New diagnostics (5 note)
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `get /v1/messages/batches`
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `post /v1/messages/batches`
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `get /v1/messages/batches/{message_batch_id}`
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `post /v1/messages/batches/{message_batch_id}/cancel`
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `get /v1/messages/batches/{message_batch_id}/results`
llama-stack-client-openapi studio · code · diff

Your SDK build had at least one "warning" diagnostic, but this did not represent a regression.
generate ⚠️

New diagnostics (5 note)
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `get /v1/messages/batches`
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `post /v1/messages/batches`
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `get /v1/messages/batches/{message_batch_id}`
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `post /v1/messages/batches/{message_batch_id}/cancel`
💡 Endpoint/NotConfigured: Skipped endpoint because it's not in your Stainless config: `get /v1/messages/batches/{message_batch_id}/results`

This comment is auto-generated by GitHub Actions and is automatically kept up to date as you push.
If you push custom code to the preview branch, re-run this workflow to update the comment.
Last updated: 2026-04-22 19:29:36 UTC

@cdoern cdoern changed the title feat(messages): add Anthropic Message Batches API feat(messages)!: add Anthropic Message Batches API Apr 16, 2026
@cdoern cdoern force-pushed the feat/messages-batches-api branch 2 times, most recently from 7f7488d to 0ed9397 Compare April 16, 2026 19:35
@ogx-ai ogx-ai deleted a comment from nidhishgajjar Apr 22, 2026
@ogx-ai ogx-ai deleted a comment from nidhishgajjar Apr 22, 2026
skamenan7 pushed a commit to skamenan7/llama-stack that referenced this pull request Apr 22, 2026
…ranslation (ogx-ai#5587)

## Summary

- Adds a new `messages-openai` integration test suite that reuses
`tests/integration/messages` with the `gpt` setup, so requests flow
through `_anthropic_to_openai` / `_openai_to_anthropic` in
`providers/inline/messages/impl.py` instead of the native passthrough
branch that the existing `messages` (ollama-reasoning) suite hits.
- Registers the suite in `tests/integration/ci_matrix.json` so
replay-mode CI runs it, and adds a `gpt` / `messages-openai` row to
`.github/workflows/record-integration-tests.yml` so future rerecord runs
refresh it.
- Includes 12 recordings captured against `openai/gpt-4o` so replay mode
works out-of-the-box (no API key required in CI).

This is a precursor to ogx-ai#5577 — the batches tests there need a suite that
targets OpenAI, because batches go through `create_message()` which only
exercises translation when the provider is not in
`_NATIVE_MESSAGES_MODULES`.

## Test plan

Recorded locally and verified against `openai/gpt-4o`:

```bash
./scripts/integration-tests.sh \
  --stack-config server:ci-tests \
  --suite messages-openai \
  --inference-mode record-if-missing
```

Result: 13/13 tests pass. Recording URLs point at
`https://api.openai.com/v1/chat/completions`, confirming the translation
path is being exercised (not the Anthropic-native `/v1/messages`
endpoint the ollama suite hits).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Charlie Doern <cdoern@redhat.com>
@cdoern cdoern force-pushed the feat/messages-batches-api branch 3 times, most recently from 4842890 to 70091ac Compare April 22, 2026 15:44
Add the 5 Anthropic Message Batches endpoints under /v1/messages:

- POST /v1/messages/batches (create batch)
- GET /v1/messages/batches (list batches)
- GET /v1/messages/batches/{id} (retrieve batch)
- POST /v1/messages/batches/{id}/cancel (cancel batch)
- GET /v1/messages/batches/{id}/results (stream JSONL results)

The implementation follows the same pattern as the existing OpenAI Batches
provider: KVStore for persistence, background asyncio tasks with
semaphore-based concurrency control, and reuse of the existing
create_message() flow for processing individual batch requests. The
MessagesConfig now requires a kvstore backend, which is a breaking change
to the provider configuration.

Integration tests run under the messages-openai suite and cover create /
retrieve / list / cancel / results / duplicate-custom_id / 404 paths against
openai/gpt-4o, with recordings committed for replay-mode CI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Charlie Doern <cdoern@redhat.com>
@cdoern cdoern force-pushed the feat/messages-batches-api branch from 70091ac to 25dae2f Compare April 22, 2026 19:28
@cdoern cdoern marked this pull request as ready for review April 22, 2026 19:47
@cdoern
Copy link
Copy Markdown
Collaborator Author

cdoern commented Apr 22, 2026

not sure why backwards compatibility test is failing, I added ! in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant