메시지 배치 생성
POST/v1/messages/batches
메시지 생성 요청의 배치를 전송합니다.
Message Batches API를 사용하면 여러 Messages API 요청을 한 번에 처리할 수 있습니다. 메시지 배치가 생성되면 즉시 처리가 시작됩니다. 배치는 완료되는 데 최대 24시간이 소요될 수 있습니다.
Message Batches API에 대한 자세한 내용은 사용자 가이드를 참조하세요.
Parameters
Returns
메시지 배치 생성
<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
$client = new Client(apiKey: 'my-anthropic-api-key');
$messageBatch = $client->messages->batches->create(
requests: [
[
'customID' => 'my-custom-id-1',
'params' => [
'maxTokens' => 1024,
'messages' => [['content' => 'Hello, world', 'role' => 'user']],
'model' => Model::CLAUDE_OPUS_5,
'cacheControl' => ['type' => 'ephemeral', 'ttl' => '5m'],
'container' => [
'id' => 'id',
'skills' => [
['skillID' => 'pdf', 'type' => 'anthropic', 'version' => 'latest']
],
],
'inferenceGeo' => 'inference_geo',
'metadata' => ['userID' => '13803d75-b4b5-4c3e-b2a2-6f21399b021b'],
'outputConfig' => [
'effort' => 'low',
'format' => ['schema' => ['foo' => 'bar'], 'type' => 'json_schema'],
],
'serviceTier' => 'auto',
'stopSequences' => ['string'],
'stream' => false,
'system' => [
[
'text' => 'Today\'s date is 2024-06-01.',
'type' => 'text',
'cacheControl' => ['type' => 'ephemeral', 'ttl' => '5m'],
'citations' => [
[
'citedText' => 'The grass is green. The sky is blue.',
'documentIndex' => 0,
'documentTitle' => 'x',
'endCharIndex' => 0,
'startCharIndex' => 0,
'type' => 'char_location',
],
],
],
],
'temperature' => 1,
'thinking' => ['type' => 'adaptive', 'display' => 'summarized'],
'toolChoice' => ['type' => 'auto', 'disableParallelToolUse' => true],
'tools' => [
[
'inputSchema' => [
'type' => 'object',
'properties' => ['location' => 'bar', 'unit' => 'bar'],
'required' => ['location'],
],
'name' => 'name',
'allowedCallers' => ['direct'],
'cacheControl' => ['type' => 'ephemeral', 'ttl' => '5m'],
'deferLoading' => true,
'description' => 'Get the current weather in a given location',
'eagerInputStreaming' => true,
'inputExamples' => [['foo' => 'bar']],
'strict' => true,
'type' => 'custom',
],
],
'topK' => 5,
'topP' => 0.7,
],
],
],
userProfileID: 'anthropic-user-profile-id',
workspaceID: 'wrkspc_011CZkZaBF1tNoB5wlCeusgy',
);
var_dump($messageBatch);Response 200
{
"id": "msgbatch_013Zva2CMHLNnXjNJJKqJ2EF",
"archived_at": "2024-08-20T18:37:24.100435Z",
"cancel_initiated_at": "2024-08-20T18:37:24.100435Z",
"created_at": "2024-08-20T18:37:24.100435Z",
"ended_at": "2024-08-20T18:37:24.100435Z",
"expires_at": "2024-08-20T18:37:24.100435Z",
"processing_status": "in_progress",
"request_counts": {
"canceled": 10,
"errored": 30,
"expired": 10,
"processing": 100,
"succeeded": 50
},
"results_url": "https://api.anthropic.com/v1/messages/batches/msgbatch_013Zva2CMHLNnXjNJJKqJ2EF/results",
"type": "message_batch"
}Returns Examples
Response 200
{
"id": "msgbatch_013Zva2CMHLNnXjNJJKqJ2EF",
"archived_at": "2024-08-20T18:37:24.100435Z",
"cancel_initiated_at": "2024-08-20T18:37:24.100435Z",
"created_at": "2024-08-20T18:37:24.100435Z",
"ended_at": "2024-08-20T18:37:24.100435Z",
"expires_at": "2024-08-20T18:37:24.100435Z",
"processing_status": "in_progress",
"request_counts": {
"canceled": 10,
"errored": 30,
"expired": 10,
"processing": 100,
"succeeded": 50
},
"results_url": "https://api.anthropic.com/v1/messages/batches/msgbatch_013Zva2CMHLNnXjNJJKqJ2EF/results",
"type": "message_batch"
}