Function Calling
استدعاء الدوال
Definition
A feature that lets an LLM request your code to run a specific function and return the result back to the LLM.
ميزة تسمح للنموذج اللغوي الكبير بطلب تشغيل دالة معينة في كودك وإعادة النتيجة إلى النموذج.
Why It Matters
Function calling is what makes AI assistants actually useful beyond answering questions. It is what allows an AI to look up your account, book a reservation, trigger a refund, or query a database. Every real-world AI product with actions uses function calling.
استدعاء الدوال هو ما يجعل مساعدي الذكاء الاصطناعي مفيدين فعلاً بما يتجاوز الإجابة على الأسئلة. هذا ما يسمح للذكاء الاصطناعي بالبحث عن حسابك وحجز موعد وتفعيل استرداد مالي أو الاستعلام عن قاعدة بيانات. كل منتج ذكاء اصطناعي للعالم الحقيقي مع إجراءات يستخدم استدعاء الدوال.
Full Definition
Example Usage
“You define: { name: "get_weather", description: "Get current weather for a city", parameters: { city: "string" } }. User says "What's the weather in Dubai?" The LLM responds with a tool call: { name: "get_weather", arguments: { city: "Dubai" } }. Your code calls the weather API and returns "Dubai: 38°C, sunny". The LLM then generates: "It's currently 38°C and sunny in Dubai."”
“تُعرّف: { name: 'get_weather', description: 'احصل على الطقس الحالي لمدينة', parameters: { city: 'string' } }. يقول المستخدم 'ما حال الطقس في دبي؟' يردّ النموذج باستدعاء أداة: { name: 'get_weather', arguments: { city: 'Dubai' } }. يستدعي كودك واجهة برمجة الطقس ويُعيد 'دبي: 38°م، مشمس'. يُنشئ النموذج بعدها: 'الطقس في دبي حالياً 38°م ومشمس.'”
AI Builder Tips
Avoid these mistakes when using Function Calling:
Writing vague function descriptions — the LLM uses the description to decide when to call the function; vague descriptions lead to wrong calls
Not validating function arguments from the LLM before executing — the LLM may hallucinate invalid arguments
Giving the LLM access to destructive functions (delete, payment) without a confirmation step
Sign in to unlock guided AI explanations from AI Teacher.
Generate a Prompt
Copy this prompt and use it directly with any AI model — no setup needed.
Help me build a project using Function Calling. Explain: 1. What is Function Calling and why it matters 2. The core architecture and required tools 3. Step-by-step implementation plan 4. Common mistakes to avoid: Writing vague function descriptions — the LLM uses the description to decide when to call the function; vague descriptions lead to wrong calls, Not validating function arguments from the LLM before executing — the LLM may hallucinate invalid arguments, Giving the LLM access to destructive functions (delete, payment) without a confirmation step 5. Best practices and production tips