Skip to main content
Function calling depends on the selected model. Use the Models API to find models with tools_calling: true.
Bind model outputs to your own logic with tool calls. This guide shows how to declare a function, let the model request it, and return the result to finish the conversation.

Prerequisites

  • Python 3.9+ with requests installed
  • An LLM7.io token set in API_KEY
  • Access to https://api.llm7.io/v1/chat/completions

Full example

This end-to-end example asks for the weather in London, lets the model request your get_weather tool, and sends back mocked data.

Key parameters

  • tools: JSON Schema that declares each function you will allow the model to call.
  • tool_choice: "auto": Lets the model decide whether to call your tool or answer directly.
  • tool_calls[*].id: Connects the model’s request to your function output; return it in the tool_call_id field.
  • messages: Keep the full conversation history plus the tool call and its response so the model can produce a final answer.