Close Menu
  • AI
  • Content Creation
  • Tech
  • Robotics
AI-trends.todayAI-trends.today
  • AI
  • Content Creation
  • Tech
  • Robotics
Trending
  • DeepSeek AI releases DeepSeek V4: Sparse attention and heavily compressed attention enable one-million-token contexts.
  • AI-Designed drugs by a DeepMind spinoff are headed to human trials
  • Apple’s new CEO must launch an AI killer product
  • OpenMythos Coding Tutorial: Recurrent-Depth Transformers, Depth Extrapolation and Mixture of Experts Routing
  • 5 Reasons to Think Twice Before Using ChatGPT—or Any Chatbot—for Financial Advice
  • OpenAI Releases GPT-5.5, a Absolutely Retrained Agentic Mannequin That Scores 82.7% on Terminal-Bench 2.0 and 84.9% on GDPval
  • Your Favorite AI Gay Thirst Traps: The Men Behind them
  • Mend Releases AI Safety Governance Framework: Masking Asset Stock, Danger Tiering, AI Provide Chain Safety, and Maturity Mannequin
AI-trends.todayAI-trends.today
Home»Tech»Use the Standard JSON Schema to Call Functions in Agents of Mistral

Use the Standard JSON Schema to Call Functions in Agents of Mistral

Tech By Gavin Wallace08/06/20254 Mins Read
Facebook Twitter LinkedIn Email
Samsung Researchers Introduced ANSE (Active Noise Selection for Generation): A
Samsung Researchers Introduced ANSE (Active Noise Selection for Generation): A
Share
Facebook Twitter LinkedIn Email

We’ll show how you can enable function calls in Mistral Agents with the JSON standard schema. By defining your function’s input parameters with a clear schema, you can make your custom tools seamlessly callable by the agent—enabling powerful, dynamic interactions.

The AviationStack API will be used to fetch real-time data on flight status. This demonstration shows how APIs from external sources can be called as functions in a Mistral Agent.

Set up Dependencies

Mistral: Install the library

Mistral API key loading

Get an API Key from https://console.mistral.ai/api-keys

From getpass import Getpass
MISTRAL_API_KEY = getpass('Enter Mistral API Key: ')

How to load the Aviation Stack API keys

The API keys are free. dashboard Get started

AVIATIONSTACK_API_KEY = getpass('Enter Aviation Stack API: ')

Step 2: Definition of the Custom Function

Next, we define a Python function get_flight_status() This function calls the AviationStack API in order to get the current status of the flight. This function takes an optional parameter flight_iata and returns important details like airline name, status of flight, airports for departure and arrival, and schedule times. It gracefully displays an error message if no flight matching is found.

Import requests
Type import Dict? params=
def get_flight_status(flight_iata=None):
    """
    Retrieve flight status using optional filters: dep_iata, arr_iata, flight_iata.
    """
    params = {
        "access_key": AVIATIONSTACK_API_KEY,
        "flight_iata": flight_iata  
    }

 Get response to requests.get"http://api.aviationstack.com/v1/flights", params=params)
 Data = response.json()

 If you want to know more about if "data" Data and information["data"]:
 The flight dataReturn["data"][0]
        return {
            "airline"Flying - a flight["airline"]["name"],
            "flight_iata"Flying - a flight["flight"]["iata"],
            "status"Flying - a flight["flight_status"],
            "departure_airport"Flying - a flight["departure"]["airport"],
            "arrival_airport"Flying - a flight["arrival"]["airport"],
            "scheduled_departure"Flying - a flight["departure"]["scheduled"],
            "scheduled_arrival"Flying - a flightReturn["arrival"]["scheduled"],
        }
    else:
        return {"error": "No flight found for the provided parameters."}

Create the Mistral Client and Agent

We create an agent that will use tool-calling in order to get real-time information about flights. This agent is named Flight Status. It uses the “mistral-medium-2505” This model is fitted with a function named get_flight_status. This tool uses a JSON-based schema and accepts only one parameter as a required: the IATA code of the flight (e.g. “AI101”). The agent will automatically activate this feature when it detects an appropriate user request, thus allowing seamless integration of natural language queries and API responses.

Mistral
client = Mistral(MISTRAL_API_KEY)

flight_status_agent = client.beta.agents.create(
    model="mistral-medium-2505",
    description="Provides real-time flight status using aviationstack API.",
    name="Flight Status Agent",
    tools=[
        {
            "type": "function",
            "function": {
                "name": "get_flight_status",
                "description": "Retrieve the current status of a flight by its IATA code (e.g. AI101).",
                "parameters": {
                    "type": "object",
                    "properties": {
                        "flight_iata": {
                            "type": "string",
                            "description": "IATA code of the flight (e.g. AI101)"
                        },
                    },
                    "required": ["flight_iata"]
                }
            }
        }
    ]
)

Start the conversation and handle function calling

This step involves asking the flight status agent a question in natural language. “What’s the current status of AI101?”. The Mistral Model detects the need to call get_flight_status, and it returns a Function Call Request. Then we parse and run the AviationStack API to execute the function. We then return the results back to the agent via FunctionResultEntry. The model then incorporates API responses and creates a reply in natural language with the flight status. This is printed to the console.

Import FunctionResultEntry from Mistralai
Download json

A user initiates a conversation
response = client.beta.conversations.start(
    agent_id=flight_status_agent.id,
    inputs=[{"role": "user", "content": "What's the current status of AI101?"}]
)

# Verify if the model has requested that a call to a specific function be made.
if response.outputs[-1].type == "function.call" Outputs and responses[-1].name == "get_flight_status":
    args = json.loads(response.outputs[-1].arguments)

 Run the function
    function_result = json.dumps(get_flight_status(**args))

    # Create result entry
    result_entry = FunctionResultEntry(
        tool_call_id=response.outputs[-1].tool_call_id,
        result=function_result
    )

 Agent: Return the result #
    response = client.beta.conversations.append(
        conversation_id=response.conversation_id,
        inputs=[result_entry]
    )

    print(response.outputs[-1].content)
else:
    print(response.outputs[-1].content)

Take a look at the Notebook on GitHub. The researchers are the sole owners of all credit. Also, feel free to follow us on Twitter Don’t forget about our 95k+ ML SubReddit Subscribe Now our Newsletter.


I’m a Civil Engineering graduate (2022) at Jamia Millia Islamia in New Delhi. I’m interested in Data Science and especially Neural networks and how they can be applied in different areas.

Share. Facebook Twitter LinkedIn Email
Avatar
Gavin Wallace

Related Posts

DeepSeek AI releases DeepSeek V4: Sparse attention and heavily compressed attention enable one-million-token contexts.

24/04/2026

OpenMythos Coding Tutorial: Recurrent-Depth Transformers, Depth Extrapolation and Mixture of Experts Routing

24/04/2026

OpenAI Releases GPT-5.5, a Absolutely Retrained Agentic Mannequin That Scores 82.7% on Terminal-Bench 2.0 and 84.9% on GDPval

24/04/2026

Mend Releases AI Safety Governance Framework: Masking Asset Stock, Danger Tiering, AI Provide Chain Safety, and Maturity Mannequin

24/04/2026
Top News

Grok’s sexual content is more graphic than X

Some Democrats believe that AI will help the party win elections

The ChatGPT is making people think they’re gods, and their families are terrified

Anthropic’s plan is to stop its AI from developing a nuclear weapons. Does It Work?

McDonald’s AI Hiring Bot Exposed Millions of Applicants’ Data to Hackers Using the Password ‘123456′

Load More
AI-Trends.Today

Your daily source of AI news and trends. Stay up to date with everything AI and automation!

X (Twitter) Instagram
Top Insights

WhatsApp Warning: UK Parents Scammed Out of £500K by AI That Pretends to Be Their Kids

27/05/2025

Mend Releases AI Safety Governance Framework: Masking Asset Stock, Danger Tiering, AI Provide Chain Safety, and Maturity Mannequin

24/04/2026
Latest News

DeepSeek AI releases DeepSeek V4: Sparse attention and heavily compressed attention enable one-million-token contexts.

24/04/2026

AI-Designed drugs by a DeepMind spinoff are headed to human trials

24/04/2026
X (Twitter) Instagram
  • Privacy Policy
  • Contact Us
  • Terms and Conditions
© 2026 AI-Trends.Today

Type above and press Enter to search. Press Esc to cancel.