Function Schema Builder

Build function/tool schemas for OpenAI and Anthropic function calling

Function Definition

Parameters

{
  "type": "function",
  "function": {
    "name": "get_weather",
    "description": "Get the current weather for a location",
    "parameters": {
      "type": "object",
      "properties": {
        "location": {
          "type": "string",
          "description": "City and country, e.g., 'London, UK'"
        },
        "unit": {
          "type": "string",
          "description": "Temperature unit",
          "enum": [
            "celsius",
            "fahrenheit"
          ]
        }
      },
      "required": [
        "location"
      ]
    }
  }
}

Related Tools

Function Schema Builder: Create Tool Definitions for LLM Function Calling

Function calling (also called tool use) allows LLMs to invoke external functions and APIs. This builder helps you create properly formatted function schemas for both OpenAI and Anthropic, ensuring your tools work correctly with each provider's API.

Define your function's name, description, and parameters, and the builder will generate the correct JSON schema for each provider.

Best Practices for Function Definitions

Function Names

Use snake_case and be descriptive: get_weather, search_documents, create_calendar_event. Avoid generic names like do_action.

Descriptions

Clear descriptions help the model decide when to use the function. Include what it does, when to use it, and any important constraints.

Parameter Descriptions

Include examples in descriptions: "City and country, e.g., 'London, UK'" is better than just "Location". Use enum when there are fixed valid values.

Related Tools