A zero-dependency Python micro-tool that uses reflection (inspect) to automatically generate function calling JSON schemas for OpenAI (GPT-4o, Groq, Ollama) and Anthropic (Claude 3/3.5) directly from your Python functions.
pip install function-schema-generatorimport json
from function_schema_generator import generate_openai_schema, generate_anthropic_schema
def get_stock_price(ticker: str, currency: str = "USD"):
"""Fetches the current stock price for a given ticker symbol."""
pass
# Generate OpenAI Format
openai_schema = generate_openai_schema(get_stock_price)
print("OpenAI Schema:\n", json.dumps(openai_schema, indent=2))
# Generate Anthropic (Claude) Format
anthropic_schema = generate_anthropic_schema(get_stock_price)
print("Anthropic Schema:\n", json.dumps(anthropic_schema, indent=2))