import anthropic
from anthropic.types.message_create_params import MessageCreateParamsNonStreaming
from anthropic.types.messages.batch_create_params import Request
client = anthropic.Anthropic()
message_batch = client.messages.batches.create(
requests=[
Request(
custom_id=f"{'a'*65}",
params=MessageCreateParamsNonStreaming(
model="claude-opus-4-20250514",
max_tokens=1024,
messages=[{
"role": "user",
"content": "Hello, world",
}]
)
),
Request(
custom_id=f"{'b'*65}",
params=MessageCreateParamsNonStreaming(
model="claude-opus-4-20250514",
max_tokens=1024,
messages=[{
"role": "user",
"content": "Hi again, friend",
}]
)
)
]
)
BadRequestError: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'requests.0.custom_id: String should have at most 64 characters'}}
I checked the documentation (first with cmd-f and then using claude research ;) ) for the character limit for the custom_id parameter of 64 characters and it's not listed anywhere.
creating a request via
Will cause
I checked the documentation (first with cmd-f and then using claude research ;) ) for the character limit for the custom_id parameter of 64 characters and it's not listed anywhere.