엄격한 도구 사용
엄격한 도구 사용 (Strict tool use)
도구 정의에 strict: true를 설정하면 모델의 토큰 샘플링을 스키마에 맞는 출력으로 제약해서(문법 제한 샘플링이라고 해요), Claude의 도구 입력이 JSON Schema와 일치한다는 것을 보장해 줘요. 이 페이지는 엄격 모드가 에이전트에 왜 중요한지, 어떻게 켜는지, 흔한 사용 사례를 다뤄요. 지원되는 JSON Schema 부분집합은 JSON Schema 한계를, 비엄격 스키마 안내는 도구 정의하기를 참고하세요.
출처: 문서
본문
도구 정의에 strict: true를 설정하면 Claude의 도구 입력이 우리 JSON Schema와 일치한다는 것을 보장해 줘요. 모델의 토큰 샘플링을 스키마에 맞는 출력으로 제약하는 방식(문법 제한 샘플링이라고 함)으로요. 이 페이지는 엄격 모드가 에이전트에 왜 중요한지, 어떻게 활성화하는지, 흔한 사용 사례를 다뤄요. 지원되는 JSON Schema 부분집합은 JSON Schema 한계를, 비엄격 스키마 안내는 도구 정의하기를 참고하세요.
엄격한 도구 사용은 도구 매개변수를 검증해서 Claude가 올바른 타입의 인자로 우리 함수를 호출하도록 해 줘요. 다음과 같은 경우 엄격한 도구 사용이 필요해요:
- 도구 매개변수를 검증할 때
- 에이전틱 워크플로를 구축할 때
- 타입 안전한 함수 호출을 보장할 때
- 중첩된 속성이 있는 복잡한 도구를 처리할 때
엄격한 도구 사용이 에이전트에 중요한 이유 (Why strict tool use matters for agents)
신뢰할 수 있는 에이전틱 시스템을 구축하려면 스키마 일치가 보장되어야 해요. 엄격 모드가 없으면 Claude가 호환되지 않는 타입(2 대신 "2")을 반환하거나 필수 필드를 빠뜨려서 우리 함수를 깨뜨리고 런타임 오류를 일으킬 수 있어요.
엄격한 도구 사용은 타입 안전한 매개변수를 보장해요:
- 함수가 매번 올바른 타입의 인자를 받아요
- 도구 호출을 검증하고 재시도할 필요가 없어요
- 규모에 따라 일관되게 동작하는 프로덕션 준비 에이전트
예를 들어 예약 시스템이 passengers: int를 필요로 한다고 해 볼게요. 엄격 모드가 없으면 Claude가 passengers: "two"나 passengers: "2"를 제공할 수 있어요. strict: true를 쓰면 응답에 항상 passengers: 2가 담겨요.
빠른 시작 (Quick start)
ant messages create --transform content <<'YAML'
model: claude-opus-5-5
max_tokens: 1024
messages:
- role: user
content: What is the weather in San Francisco?
tools:
- name: get_weather
description: Get the current weather in a given location
strict: true
input_schema:
type: object
properties:
location:
type: string
description: The city and state, e.g. San Francisco, CA
unit:
type: string
enum: [celsius, fahrenheit]
required: [location]
additionalProperties: false
YAML
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
messages=[{"role": "user", "content": "What's the weather like in San Francisco?"}],
tools=[
{
"name": "get_weather",
"description": "Get the current weather in a given location",
"strict": True, # Enable strict mode
"input_schema": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"],
"description": "The unit of temperature, either 'celsius' or 'fahrenheit'",
},
},
"required": ["location"],
"additionalProperties": False,
},
}
],
)
print(response.content)
const client = new Anthropic({
apiKey: proces..._KEY
});
const response = await client.messages.create({
model: "claude-opus-5-5",
max_tokens: 1024,
messages: [
{
role: "user",
content: "What's the weather like in San Francisco?"
}
],
tools: [
{
name: "get_weather",
description: "Get the current weather in a given location",
strict: true, // Enable strict mode
input_schema: {
type: "object",
properties: {
location: {
type: "string",
description: "The city and state, e.g. San Francisco, CA"
},
unit: {
type: "string",
enum: ["celsius", "fahrenheit"]
}
},
required: ["location"],
additionalProperties: false
}
}
]
});
console.log(response.content);
using System.Text.Json;
using Anthropic;
using Anthropic.Models.Messages;
AnthropicClient client = new();
var parameters = new MessageCreateParams
{
Model = Model.ClaudeOpus5_5,
MaxTokens = 1024,
Messages = [new() { Role = Role.User, Content = "What's the weather like in San Francisco?" }],
Tools = [
new ToolUnion(new Tool()
{
Name = "get_weather",
Description = "Get the current weather in a given location",
Strict = true,
InputSchema = new InputSchema(new Dictionary<string, JsonElement>
{
["properties"] = JsonSerializer.SerializeToElement(new Dictionary<string, object>
{
["location"] = new { type = "string", description = "The city and state, e.g. San Francisco, CA" },
["unit"] = new { type = "string", @enum = new[] { "celsius", "fahrenheit" } },
}),
["required"] = JsonSerializer.SerializeToElement(new[] { "location" }),
["additionalProperties"] = JsonSerializer.SerializeToElement(false),
}),
}),
]
};
var message = await client.Messages.Create(parameters);
Console.WriteLine(message);
client := anthropic.NewClient()
response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
Model: anthropic.ModelClaudeOpus5_5,
MaxTokens: 1024,
Messages: []anthropic.MessageParam{
anthropic.NewUserMessage(anthropic.NewTextBlock("What's the weather like in San Francisco?")),
},
Tools: []anthropic.ToolUnionParam{
{OfTool: &anthropic.ToolParam{
Name: "get_weather",
Description: anthropic.String("Get the current weather in a given location"),
Strict: anthropic.Bool(true),
InputSchema: anthropic.ToolInputSchemaParam{
Properties: map[string]any{
"location": map[string]any{
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"unit": map[string]any{
"type": "string",
"enum": []string{"celsius", "fahrenheit"},
},
},
Required: []string{"location"},
ExtraFields: map[string]any{
"additionalProperties": false,
},
}}},
},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(response.Content)
AnthropicClient client = AnthropicOkHttpClient.fromEnv();
InputSchema schema = InputSchema.builder()
.properties(
JsonValue.from(
Map.of(
"location", Map.of(
"type", "string",
"description", "The city and state, e.g. San Francisco, CA"
),
"unit", Map.of(
"type", "string",
"enum", List.of("celsius", "fahrenheit")
)
)
)
)
.putAdditionalProperty("required", JsonValue.from(List.of("location")))
.putAdditionalProperty("additionalProperties", JsonValue.from(false))
.build();
MessageCreateParams params = MessageCreateParams.builder()
.model(Model.CLAUDE_OPUS_5_5)
.maxTokens(1024L)
.addUserMessage("What's the weather like in San Francisco?")
.addTool(
Tool.builder()
.name("get_weather")
.description("Get the current weather in a given location")
.strict(true)
.inputSchema(schema)
.build()
)
.build();
Message response = client.messages().create(params);
IO.println(response.content());
$client = new Client();
$message = $client->messages->create(
maxTokens: 1024,
messages: [
['role' => 'user', 'content' => "What's the weather like in San Francisco?"]
],
model: 'claude-opus-5-5',
tools: [
[
'name' => 'get_weather',
'description' => 'Get the current weather in a given location',
'strict' => true,
'input_schema' => [
'type' => 'object',
'properties' => [
'location' => [
'type' => 'string',
'description' => 'The city and state, e.g. San Francisco, CA'
],
'unit' => [
'type' => 'string',
'enum' => ['celsius', 'fahrenheit']
]
],
'required' => ['location'],
'additionalProperties' => false
]
]
],
);
echo $message;
client = Anthropic::Client.new
message = client.messages.create(
model: "claude-opus-5-5",
max_tokens: 1024,
messages: [
{ role: "user", content: "What's the weather like in San Francisco?" }
],
tools: [
{
name: "get_weather",
description: "Get the current weather in a given location",
strict: true,
input_schema: {
type: "object",
properties: {
location: {
type: "string",
description: "The city and state, e.g. San Francisco, CA"
},
unit: {
type: "string",
enum: ["celsius", "fahrenheit"]
}
},
required: ["location"],
additionalProperties: false
}
}
]
)
puts message.content
응답 형식: response.content[x].input에 검증된 입력이 있는 도구 사용 블록
{
"type": "tool_use",
"name": "get_weather",
"input": {
"location": "San Francisco, CA"
}
}
보장:
- 도구
input이input_schema를 엄격히 따름 - 도구
name이 항상 유효함(제공된 도구나 서버 도구에서)
동작 방식 (How it works)
컴퓨터 사용과 브라우저 사용 툴셋 항목(computer_toolset_20260801과 browser_toolset_20260801)은 strict: true를 받지 않아요. 둘 중 하나에 설정하면 요청이 거부돼요.
흔한 사용 사례 (Common use cases)
<CodeGroup>
```bash cURL
curl https://api.anthropic.com/v1/messages \
-H "content-type: application/json" \
-H "x-api-key: $ANTHR...KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-opus-5-5",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Search for flights to Tokyo departing June 1, 2026"}
],
"tools": [{
"name": "search_flights",
"strict": true,
"input_schema": {
"type": "object",
"properties": {
"destination": {"type": "string"},
"departure_date": {"type": "string", "format": "date"},
"passengers": {"type": "integer", "enum": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}
},
"required": ["destination", "departure_date"],
"additionalProperties": false
}
}]
}'
```
```bash CLI
ant messages create <<'YAML'
model: claude-opus-5-5
max_tokens: 1024
messages:
- role: user
content: Search for flights to Tokyo departing June 1, 2026
tools:
- name: search_flights
strict: true
input_schema:
type: object
properties:
destination:
type: string
departure_date:
type: string
format: date
passengers:
type: integer
enum: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
required: [destination, departure_date]
additionalProperties: false
YAML
```
```python Python
client = Anthropic()
response = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
messages=[
{
"role": "user",
"content": "Search for flights to Tokyo departing June 1, 2026",
}
],
tools=[
{
"name": "search_flights",
"strict": True,
"input_schema": {
"type": "object",
"properties": {
"destination": {"type": "string"},
"departure_date": {"type": "string", "format": "date"},
"passengers": {
"type": "integer",
"enum": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
},
},
"required": ["destination", "departure_date"],
"additionalProperties": False,
},
}
],
)
print(response)
```
```typescript TypeScript
const client = new Anthropic();
const searchFlightsTool: Anthropic.Tool = {
name: "search_flights",
strict: true,
input_schema: {
type: "object",
properties: {
destination: { type: "string" },
departure_date: { type: "string", format: "date" },
passengers: { type: "integer", enum: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] }
},
required: ["destination", "departure_date"],
additionalProperties: false
}
};
const response = await client.messages.create({
model: "claude-opus-5-5",
max_tokens: 1024,
messages: [{ role: "user", content: "Search for flights to Tokyo departing June 1, 2026" }],
tools: [searchFlightsTool]
});
console.log(response);
```
```csharp C#
using System.Text.Json;
using Anthropic;
using Anthropic.Models.Messages;
AnthropicClient client = new();
var parameters = new MessageCreateParams
{
Model = Model.ClaudeOpus5_5,
MaxTokens = 1024,
Messages = [new() { Role = Role.User, Content = "Search for flights to Tokyo departing June 1, 2026" }],
Tools = [
new ToolUnion(new Tool()
{
Name = "search_flights",
Strict = true,
InputSchema = new InputSchema(new Dictionary<string, JsonElement>
{
["properties"] = JsonSerializer.SerializeToElement(new Dictionary<string, object>
{
["destination"] = new { type = "string" },
["departure_date"] = new { type = "string", format = "date" },
["passengers"] = new { type = "integer", @enum = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } },
}),
["required"] = JsonSerializer.SerializeToElement(new[] { "destination", "departure_date" }),
["additionalProperties"] = JsonSerializer.SerializeToElement(false),
}),
}),
]
};
var message = await client.Messages.Create(parameters);
Console.WriteLine(message);
```
```go Go
client := anthropic.NewClient()
response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
Model: anthropic.ModelClaudeOpus5_5,
MaxTokens: 1024,
Messages: []anthropic.MessageParam{
anthropic.NewUserMessage(anthropic.NewTextBlock("Search for flights to Tokyo departing June 1, 2026")),
},
Tools: []anthropic.ToolUnionParam{
{OfTool: &anthropic.ToolParam{
Name: "search_flights",
Strict: anthropic.Bool(true),
InputSchema: anthropic.ToolInputSchemaParam{
Properties: map[string]any{
"destination": map[string]any{
"type": "string",
},
"departure_date": map[string]any{
"type": "string",
"format": "date",
},
"passengers": map[string]any{
"type": "integer",
"enum": []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
},
},
Required: []string{"destination", "departure_date"},
ExtraFields: map[string]any{
"additionalProperties": false,
},
}}},
},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(response.RawJSON())
```
```java Java
AnthropicClient client = AnthropicOkHttpClient.fromEnv();
InputSchema schema = InputSchema.builder()
.properties(
JsonValue.from(
Map.of(
"destination", Map.of("type", "string"),
"departure_date", Map.of("type", "string", "format", "date"),
"passengers", Map.of(
"type", "integer",
"enum", List.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
)
)
)
)
.putAdditionalProperty("required", JsonValue.from(List.of("destination", "departure_date")))
.putAdditionalProperty("additionalProperties", JsonValue.from(false))
.build();
MessageCreateParams params = MessageCreateParams.builder()
.model(Model.CLAUDE_OPUS_5_5)
.maxTokens(1024L)
.addUserMessage("Search for flights to Tokyo departing June 1, 2026")
.addTool(
Tool.builder()
.name("search_flights")
.strict(true)
.inputSchema(schema)
.build()
)
.build();
Message response = client.messages().create(params);
IO.println(response);
```
```php PHP
$client = new Client();
$message = $client->messages->create(
maxTokens: 1024,
messages: [
['role' => 'user', 'content' => 'Search for flights to Tokyo departing June 1, 2026']
],
model: 'claude-opus-5-5',
tools: [
[
'name' => 'search_flights',
'strict' => true,
'input_schema' => [
'type' => 'object',
'properties' => [
'destination' => ['type' => 'string'],
'departure_date' => ['type' => 'string', 'format' => 'date'],
'passengers' => [
'type' => 'integer',
'enum' => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
]
],
'required' => ['destination', 'departure_date'],
'additionalProperties' => false
]
]
],
);
echo $message;
```
```ruby Ruby
client = Anthropic::Client.new
message = client.messages.create(
model: "claude-opus-5-5",
max_tokens: 1024,
messages: [
{ role: "user", content: "Search for flights to Tokyo departing June 1, 2026" }
],
tools: [
{
name: "search_flights",
strict: true,
input_schema: {
type: "object",
properties: {
destination: { type: "string" },
departure_date: { type: "string", format: "date" },
passengers: {
type: "integer",
enum: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
}
},
required: ["destination", "departure_date"],
additionalProperties: false
}
}
]
)
puts message
```
</CodeGroup>
<CodeGroup>
```bash cURL
curl https://api.anthropic.com/v1/messages \
-H "content-type: application/json" \
-H "x-api-key: $ANTHR...KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-opus-5-5",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Help me plan a trip from New York to Paris for 2 people, departing June 1, 2026"}
],
"tools": [
{
"name": "search_flights",
"strict": true,
"input_schema": {
"type": "object",
"properties": {
"origin": {"type": "string"},
"destination": {"type": "string"},
"departure_date": {"type": "string", "format": "date"},
"travelers": {"type": "integer", "enum": [1, 2, 3, 4, 5, 6]}
},
"required": ["origin", "destination", "departure_date"],
"additionalProperties": false
}
},
{
"name": "search_hotels",
"strict": true,
"input_schema": {
"type": "object",
"properties": {
"city": {"type": "string"},
"check_in": {"type": "string", "format": "date"},
"guests": {"type": "integer", "enum": [1, 2, 3, 4]}
},
"required": ["city", "check_in"],
"additionalProperties": false
}
}
]
}'
```
```bash CLI
ant messages create <<'YAML'
model: claude-opus-5-5
max_tokens: 1024
messages:
- role: user
content: >-
Help me plan a trip from New York to Paris for 2 people,
departing June 1, 2026
tools:
- name: search_flights
strict: true
input_schema:
type: object
properties:
origin: {type: string}
destination: {type: string}
departure_date: {type: string, format: date}
travelers: {type: integer, enum: [1, 2, 3, 4, 5, 6]}
required: [origin, destination, departure_date]
additionalProperties: false
- name: search_hotels
strict: true
input_schema:
type: object
properties:
city: {type: string}
check_in: {type: string, format: date}
guests: {type: integer, enum: [1, 2, 3, 4]}
required: [city, check_in]
additionalProperties: false
YAML
```
```python Python
client = Anthropic()
response = client.messages.create(
model="claude-opus-5-5",
max_tokens=1024,
messages=[
{
"role": "user",
"content": "Help me plan a trip from New York to Paris for 2 people, departing June 1, 2026",
}
],
tools=[
{
"name": "search_flights",
"strict": True,
"input_schema": {
"type": "object",
"properties": {
"origin": {"type": "string"},
"destination": {"type": "string"},
"departure_date": {"type": "string", "format": "date"},
"travelers": {"type": "integer", "enum": [1, 2, 3, 4, 5, 6]},
},
"required": ["origin", "destination", "departure_date"],
"additionalProperties": False,
},
},
{
"name": "search_hotels",
"strict": True,
"input_schema": {
"type": "object",
"properties": {
"city": {"type": "string"},
"check_in": {"type": "string", "format": "date"},
"guests": {"type": "integer", "enum": [1, 2, 3, 4]},
},
"required": ["city", "check_in"],
"additionalProperties": False,
},
},
],
)
print(response)
```
```typescript TypeScript
const client = new Anthropic();
const tools: Anthropic.Tool[] = [
{
name: "search_flights",
strict: true,
input_schema: {
type: "object",
properties: {
origin: { type: "string" },
destination: { type: "string" },
departure_date: { type: "string", format: "date" },
travelers: { type: "integer", enum: [1, 2, 3, 4, 5, 6] }
},
required: ["origin", "destination", "departure_date"],
additionalProperties: false
}
},
{
name: "search_hotels",
strict: true,
input_schema: {
type: "object",
properties: {
city: { type: "string" },
check_in: { type: "string", format: "date" },
guests: { type: "integer", enum: [1, 2, 3, 4] }
},
required: ["city", "check_in"],
additionalProperties: false
}
}
];
const response = await client.messages.create({
model: "claude-opus-5-5",
max_tokens: 1024,
messages: [
{
role: "user",
content:
"Help me plan a trip from New York to Paris for 2 people, departing June 1, 2026"
}
],
tools: tools
});
console.log(response);
```
```csharp C#
using System.Text.Json;
using Anthropic;
using Anthropic.Models.Messages;
AnthropicClient client = new();
var parameters = new MessageCreateParams
{
Model = Model.ClaudeOpus5_5,
MaxTokens = 1024,
Messages = [new() { Role = Role.User, Content = "Help me plan a trip from New York to Paris for 2 people, departing June 1, 2026" }],
Tools = [
new ToolUnion(new Tool()
{
Name = "search_flights",
Strict = true,
InputSchema = new InputSchema(new Dictionary<string, JsonElement>
{
["properties"] = JsonSerializer.SerializeToElement(new Dictionary<string, object>
{
["origin"] = new { type = "string" },
["destination"] = new { type = "string" },
["departure_date"] = new { type = "string", format = "date" },
["travelers"] = new { type = "integer", @enum = new[] { 1, 2, 3, 4, 5, 6 } },
}),
["required"] = JsonSerializer.SerializeToElement(new[] { "origin", "destination", "departure_date" }),
["additionalProperties"] = JsonSerializer.SerializeToElement(false),
}),
}),
new ToolUnion(new Tool()
{
Name = "search_hotels",
Strict = true,
InputSchema = new InputSchema(new Dictionary<string, JsonElement>
{
["properties"] = JsonSerializer.SerializeToElement(new Dictionary<string, object>
{
["city"] = new { type = "string" },
["check_in"] = new { type = "string", format = "date" },
["guests"] = new { type = "integer", @enum = new[] { 1, 2, 3, 4 } },
}),
["required"] = JsonSerializer.SerializeToElement(new[] { "city", "check_in" }),
["additionalProperties"] = JsonSerializer.SerializeToElement(false),
}),
}),
]
};
var message = await client.Messages.Create(parameters);
Console.WriteLine(message);
```
```go Go
client := anthropic.NewClient()
response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
Model: anthropic.ModelClaudeOpus5_5,
MaxTokens: 1024,
Messages: []anthropic.MessageParam{
anthropic.NewUserMessage(anthropic.NewTextBlock("Help me plan a trip from New York to Paris for 2 people, departing June 1, 2026")),
},
Tools: []anthropic.ToolUnionParam{
{OfTool: &anthropic.ToolParam{
Name: "search_flights",
Strict: anthropic.Bool(true),
InputSchema: anthropic.ToolInputSchemaParam{
Properties: map[string]any{
"origin": map[string]any{"type": "string"},
"destination": map[string]any{"type": "string"},
"departure_date": map[string]any{"type": "string", "format": "date"},
"travelers": map[string]any{"type": "integer", "enum": []int{1, 2, 3, 4, 5, 6}},
},
Required: []string{"origin", "destination", "departure_date"},
ExtraFields: map[string]any{
"additionalProperties": false,
},
}}},
{OfTool: &anthropic.ToolParam{
Name: "search_hotels",
Strict: anthropic.Bool(true),
InputSchema: anthropic.ToolInputSchemaParam{
Properties: map[string]any{
"city": map[string]any{"type": "string"},
"check_in": map[string]any{"type": "string", "format": "date"},
"guests": map[string]any{"type": "integer", "enum": []int{1, 2, 3, 4}},
},
Required: []string{"city", "check_in"},
ExtraFields: map[string]any{
"additionalProperties": false,
},
}}},
},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(response.RawJSON())
```
```java Java
AnthropicClient client = AnthropicOkHttpClient.fromEnv();
InputSchema flightsSchema = InputSchema.builder()
.properties(
JsonValue.from(
Map.of(
"origin", Map.of("type", "string"),
"destination", Map.of("type", "string"),
"departure_date", Map.of("type", "string", "format", "date"),
"travelers", Map.of("type", "integer", "enum", List.of(1, 2, 3, 4, 5, 6))
)
)
)
.putAdditionalProperty("required", JsonValue.from(List.of("origin", "destination", "departure_date")))
.putAdditionalProperty("additionalProperties", JsonValue.from(false))
.build();
InputSchema hotelsSchema = InputSchema.builder()
.properties(
JsonValue.from(
Map.of(
"city", Map.of("type", "string"),
"check_in", Map.of("type", "string", "format", "date"),
"guests", Map.of("type", "integer", "enum", List.of(1, 2, 3, 4))
)
)
)
.putAdditionalProperty("required", JsonValue.from(List.of("city", "check_in")))
.putAdditionalProperty("additionalProperties", JsonValue.from(false))
.build();
MessageCreateParams params = MessageCreateParams.builder()
.model(Model.CLAUDE_OPUS_5_5)
.maxTokens(1024L)
.addUserMessage("Help me plan a trip from New York to Paris for 2 people, departing June 1, 2026")
.addTool(
Tool.builder()
.name("search_flights")
.strict(true)
.inputSchema(flightsSchema)
.build()
)
.addTool(
Tool.builder()
.name("search_hotels")
.strict(true)
.inputSchema(hotelsSchema)
.build()
)
.build();
Message response = client.messages().create(params);
IO.println(response);
```
```php PHP
$client = new Client();
$message = $client->messages->create(
maxTokens: 1024,
messages: [
['role' => 'user', 'content' => 'Help me plan a trip from New York to Paris for 2 people, departing June 1, 2026']
],
model: 'claude-opus-5-5',
tools: [
[
'name' => 'search_flights',
'strict' => true,
'input_schema' => [
'type' => 'object',
'properties' => [
'origin' => ['type' => 'string'],
'destination' => ['type' => 'string'],
'departure_date' => ['type' => 'string', 'format' => 'date'],
'travelers' => ['type' => 'integer', 'enum' => [1, 2, 3, 4, 5, 6]]
],
'required' => ['origin', 'destination', 'departure_date'],
'additionalProperties' => false
]
],
[
'name' => 'search_hotels',
'strict' => true,
'input_schema' => [
'type' => 'object',
'properties' => [
'city' => ['type' => 'string'],
'check_in' => ['type' => 'string', 'format' => 'date'],
'guests' => ['type' => 'integer', 'enum' => [1, 2, 3, 4]]
],
'required' => ['city', 'check_in'],
'additionalProperties' => false
]
]
],
);
echo $message;
```
```ruby Ruby
client = Anthropic::Client.new
message = client.messages.create(
model: "claude-opus-5-5",
max_tokens: 1024,
messages: [
{ role: "user", content: "Help me plan a trip from New York to Paris for 2 people, departing June 1, 2026" }
],
tools: [
{
name: "search_flights",
strict: true,
input_schema: {
type: "object",
properties: {
origin: { type: "string" },
destination: { type: "string" },
departure_date: { type: "string", format: "date" },
travelers: { type: "integer", enum: [1, 2, 3, 4, 5, 6] }
},
required: ["origin", "destination", "departure_date"],
additionalProperties: false
}
},
{
name: "search_hotels",
strict: true,
input_schema: {
type: "object",
properties: {
city: { type: "string" },
check_in: { type: "string", format: "date" },
guests: { type: "integer", enum: [1, 2, 3, 4] }
},
required: ["city", "check_in"],
additionalProperties: false
}
}
]
)
puts message
```
</CodeGroup>
데이터 보존 (Data retention)
엄격한 도구 사용은 구조화 출력과 같은 파이프라인으로 도구 input_schema 정의를 문법으로 컴파일해요. 도구 스키마는 마지막 사용 이후 최대 24시간 동안 임시로 캐시돼요. 프롬프트와 응답은 API 응답 너머로 보존되지 않아요.
엄격한 도구 사용은 HIPAA 자격이 있지만, 보호된 건강 정보(PHI)는 도구 스키마 정의에 포함하면 안 돼요. API는 컴파일된 스키마를 메시지 콘텐츠와 분리해 캐시하고, 이 캐시된 스키마는 프롬프트·응답과 같은 PHI 보호를 받지 않아요. input_schema 속성 이름, enum 값, const 값, pattern 정규식에 PHI를 포함하지 마세요. PHI는 HIPAA 보호 장치 아래 보호되는 메시지 콘텐츠(프롬프트와 응답)에만 나타나야 해요.
모든 기능의 ZDR과 HIPAA 자격은 API와 데이터 보존을 참고하세요.