Pattern 1: Chat Completions loop
- Send user message + tool definitions.
- If
finish_reasonistool_calls, execute each tool call. - Send tool outputs back as
role: "tool"messages. - Read final assistant answer.
Request (continuation)
Pattern 2: Responses loop
For/v1/responses, model tool calls appear as output items of type function_call.
Then send a follow-up request with function_call_output input items.
Request (follow-up)
Endpoint selection
- Prefer
/v1/chat/completionsif you already use OpenAI-style message loops. - Prefer
/v1/responsesif your app is standardized on the Responses API. - Use
/v1/messagesif your app is Anthropic-native.