examples/batch_results.py
raw| 1 | import sys |
| 2 | import time |
| 3 | |
| 4 | import rich |
| 5 | |
| 6 | from anthropic import Anthropic |
| 7 | |
| 8 | client = Anthropic() |
| 9 | |
| 10 | try: |
| 11 | batch_id = sys.argv[1] |
| 12 | except IndexError as exc: |
| 13 | raise RuntimeError("must specify a message batch ID, `python examples/batch_results.py msgbatch_123`") from exc |
| 14 | |
| 15 | s = time.monotonic() |
| 16 | |
| 17 | result_stream = client.messages.batches.results(batch_id) |
| 18 | for result in result_stream: |
| 19 | rich.print(result) |