chatWithTools method

  1. @override
Future<ChatResponse> chatWithTools(
  1. List<ChatMessage> messages,
  2. List<Tool>? tools
)
override

Send a chat request with optional tool support

API Reference: https://docs.anthropic.com/en/api/messages

Supports all Anthropic message types including text, images, PDFs, tool calls, and extended thinking for supported models.

Implementation

@override
Future<ChatResponse> chatWithTools(
  List<ChatMessage> messages,
  List<Tool>? tools,
) async {
  final requestBody =
      _requestBuilder.buildRequestBody(messages, tools, false);
  // Headers including interleaved thinking beta are automatically handled by AnthropicClient
  final responseData = await client.postJson(chatEndpoint, requestBody);
  return _parseResponse(responseData);
}