Skip to content

Conversation

Shank312
Copy link

@Shank312 Shank312 commented Oct 6, 2025

🧠 Summary

Added a new example script assistant_weather_tool.py demonstrating how to build a GPT Assistant that can call an external weather API (Open-Meteo) using the Assistants API and function calling.

This recipe helps developers understand how to connect GPT models with real-world APIs through tool integration.

💡 Motivation
The OpenAI Cookbook currently has very few end-to-end examples showing Assistants API + function calling + external APIs.
This contribution makes it easier for developers to:

Define custom tools that call real APIs

Understand tool schema design and integration

Create assistants capable of retrieving live data

📁 Files Added
examples/assistants/assistant_weather_tool.py

✅ Checklist

Code runs successfully locally

Tested with valid OPENAI_API_KEY

Added detailed docstrings and comments

Follows repo style (black, isort)

Uses environment variables (no hardcoded keys)

Provides a practical, original learning example

📸 Example Output
Assistant created. assistant_id: asst_12345
Local tool demo (Open-Meteo):
Fetching weather for New York...
Tool result: {'location': 'New York, United States', 'temperature_c': 22.5, 'windspeed_kmh': 8.6, ...}

👤 Author

Name: Shankar Kumar
GitHub: @Shank312
Email: [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant