capabilities.work

Chat Completion With Tool Calling

A 2-step recipe with ChatGPT. We can help you get access.

Recipe · 2 steps

Chat Completion With Tool Calling

with ChatGPT · Artificial Intelligence Management

Offer a function tool to a chat completion and resolve the tool call loop.

  1. Create a chat completion that offers a single function tool and lets the model decide whether to call it.
  2. Send a follow-up completion that replays the assistant tool call and supplies the tool result as a tool-role message so the model can answer.
What you'll need to have ready
  • apiKey: OpenAI API key used as the Bearer credential.
  • model: Model ID used for the completion (e.g. gpt-4o).
  • userMessage: The user message that may trigger a tool call.
  • toolName: The name of the function tool offered to the model.
  • toolResult: The simulated tool output fed back to the model.
For your developer

Arazzo workflow chatgpt:chat-completion-tool-call, 2 operations: createChatCompletion → createChatCompletion. Specs on APIs.io.