Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add assistant_weather_tool example: Assistants API + Open-Meteo tool #2178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Shank312 wants to merge 1 commit into openai:main
base: main
Choose a base branch
Loading
from Shank312:add-new-recipe-shank312

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: shankark3121999@gmail.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /