kaxil opened a new pull request, #69624:
URL: https://github.com/apache/airflow/pull/69624
`AnthropicBatchOperator` made you repeat `params["model"]` in every request
of
`requests=[{"custom_id", "params"}]`, even though the Anthropic connection
already carries a
`default_model` (`extra['model']`) that the hook's `create_message` /
`count_tokens` use.
Batches were the one path that ignored it.
Now a request that omits `model` inherits one. Resolution order:
1. the request's own `params["model"]` (unchanged; a batch can still mix
models)
2. the operator's new
[`model`](https://github.com/astronomer/airflow/blob/babd7fe0240b4b6dfdf8394c6f0527dfc8cb6fd5/providers/anthropic/src/airflow/providers/anthropic/operators/batch.py#L87)
argument
3. the connection's `default_model` (`extra['model']`, else the provider
default)
## Design notes
- This aligns the batch path with the rest of the hook: `create_message` /
`count_tokens`
already resolve `model or self.default_model`. The connection is the
natural home for "which
model", and batches now honor it.
- `params` stays a verbatim passthrough of the Anthropic `messages.create`
payload.
[`create_batch`](https://github.com/astronomer/airflow/blob/babd7fe0240b4b6dfdf8394c6f0527dfc8cb6fd5/providers/anthropic/src/airflow/providers/anthropic/hooks/anthropic.py#L425)
fills a missing `model` via
[`_apply_default_model`](https://github.com/astronomer/airflow/blob/babd7fe0240b4b6dfdf8394c6f0527dfc8cb6fd5/providers/anthropic/src/airflow/providers/anthropic/hooks/anthropic.py#L413)
without mutating the caller's request dicts, and leaves an explicit
per-request model
untouched, so mixed-model batches keep working.
- Defaulting runs after the first-party guard and deliberately skips the
Bedrock-prefix
`_resolve_model` step: the Message Batches API is first-party + AWS only,
so the Bedrock
branch is unreachable here.
## Usage
```python
# Set the model once for the whole batch instead of on every request:
AnthropicBatchOperator(
task_id="summarize",
model="claude-opus-4-8", # or omit and set extra['model'] on the
connection
requests=[
{"custom_id": "t1", "params": {"max_tokens": 1024, "messages":
[...]}},
{"custom_id": "t2", "params": {"max_tokens": 1024, "messages":
[...]}},
],
)
```
A request that sets its own `model` overrides both, so you can still mix
models within one batch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]