Gold costs have been taking pictures up these days, attracting increasingly more buyers on a regular basis. In simply the final 2 weeks, the value of pure gold has gone up 10%, marking a considerable acquire on funding. What if there was an agent that might autonomously replace you on day by day gold charges? What if the agent might even predict tomorrow’s gold costs, serving to you make the best transfer on the proper time? With o3-mini AI integration, we will develop clever techniques that may analyze monetary tendencies and generate structured insights. On this article, we’ll construct a value prediction agent with o3-mini to trace pure gold costs. It will leverage o3-mini perform calling for correct information retrieval and o3-mini’s structured output for clear, actionable predictions.
Why Ought to We Take into account Utilizing o3-mini?
There are such a lot of totally different instruments and platforms out there at this time for constructing AI brokers. Then why are we utilizing o3-mini? Effectively, listed here are the primary causes for selecting o3-mini for constructing our value prediction agent:
- Environment friendly Automation & Actual-Time Efficiency: Allows quick response instances with affordable accuracy, making it ideally suited for chatbots, coding assistants, and AI automation instruments.
- Light-weight & Price-Efficient: Runs easily on consumer-grade {hardware}, lowering cloud prices and vitality consumption.
- Robust Coding & Reasoning: Excels in debugging, code technology, and problem-solving regardless of its smaller measurement.
- Developer-Pleasant & Scalable: Helps AI integration into workflows and deploys simply on cellular and edge units.
- Versatile & Very best for Experimentation: Allows speedy prototyping for AI-driven purposes throughout automation, coding, and conversational AI.
To grasp simply how good this mannequin is, right here’s a comparability of o3-mini in opposition to different high fashions on varied customary benchmarks.
![o3-mini benchmarks](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/benchmarks.webp)
Additionally Learn: Is OpenAI’s o3-mini Higher Than DeepSeek-R1?
And right here’s how cost-effective it’s:
![o3-mini pricing](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/openaiapi.webp)
Sources:
Setting Up the Surroundings
Earlier than constructing the agent, we’ll first cowl the mandatory stipulations and arrange the atmosphere.
Conditions
Accessing the API
We will likely be utilizing two APIs right here. One OpenAI API is used to entry the o3-mini mannequin, and the opposite Serper API is used to entry the Google search engine to test at this time’s gold value.
![OpenAI API access](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/openaiapikey.webp)
Additionally Learn: Methods to Run OpenAI’s o3-mini on Google Colab?
Constructing an AI Agent Utilizing o3-mini
On this part, I’ll stroll you thru the method of constructing a gold value prediction agent utilizing o3-mini. We are going to create an agent that analyzes market tendencies and gives insights into potential value actions.
I’ll information you thru making API calls, structuring prompts, and processing the generated predictions effectively. By the top, you’ll have a working gold prediction agent able to providing data-driven gold value forecasts. So let’s start.
Now that you’ve got each APIs, let’s transfer to the code editor and construct our software.
Step 1:Â Organising Libraries and Instruments to Information AI Agent
First we will likely be importing all the mandatory libraries and instruments that we are going to want right here
import os
import pandas as pd
from datetime import datetime, timedelta
from crewai_tools import ScrapeWebsiteTool, SerperDevTool
from crewai import Agent, Activity, Crew, Course of
from langchain_openai import ChatOpenAI
import warnings
warnings.filterwarnings('ignore')
search_tool = SerperDevTool()
scrape_tool = ScrapeWebsiteTool()
- search_tool: The SerperDevTool() will assist us to entry the google search engine to retrieve the present data in our case its gold value.
- scrape_tool: The ScrapeWebsiteTool() will assist us to extract the related data from the searched webpage.
Step 2: Calling the API
To make use of the o3-mini and the google search engine first we have now to load the OpenAI and Serper API. So this block will assist us to loading the APIs.
with open("/house/vipin/Desktop/api_key/serper_api") as file:
get_serper_api_key = file.learn().strip()
with open("/house/vipin/Desktop/api_key/api_key_pro_blog.txt") as file:
api_key = file.learn().strip()
os.environ["OPENAI_API_KEY"] = api_key
os.environ["OPENAI_MODEL_NAME"] = "o3-mini-2025-01-31"
os.environ["SERPER_API_KEY"] = get_serper_api_key
Step 3: Creating Brokers and Duties
First, let’s create the required brokers and outline their duties.
Creating Brokers:
We are going to want 2 brokers:
- Gold Value Analyst agent will analyze the present value of gold available in the market. Extracts structured information on gold costs and identifies macroeconomic components influencing value actions.
- Value Predictor agent will forecast whether or not the gold value will rise or fall primarily based on historic and macroeconomic information and use previous value tendencies, financial indicators, and machine studying insights to make day by day predictions.
Gold Value Analyst
The Gold Value Knowledge Analyst Agent gathers real-time gold costs and analyzes financial components reminiscent of inflation, foreign money fluctuations, and world market tendencies. It gives structured insights that assist refine market predictions.
gold_price_analyst_agent = Agent(
function="Gold Value Knowledge Analyst",
objective="Repeatedly monitor and analyze 24K gold value in India from {url}.",
backstory="This agent makes a speciality of commodity value monitoring, extracting structured information from {url}, and analyzing macroeconomic tendencies affecting gold costs.",
verbose=True,
allow_delegation=True,
instruments=[scrape_tool, search_tool]
)
Value Predictor
The Gold Value Predictor Agent makes use of machine studying fashions to forecast future gold value actions each day. It processes historic information and macroeconomic insights from the Analyst Agent to generate correct predictions, constantly refining its mannequin primarily based on precise market tendencies.
gold_price_predictor_agent = Agent(
function="Gold Value Predictor",
objective="Predict whether or not 24K gold value in India will go up or down tomorrow utilizing previous information and macroeconomic tendencies.",
backstory="Utilizing historic information, macroeconomic tendencies, and machine studying insights, this agent predicts day by day gold value actions and backtests predictions for accuracy.",
verbose=True,
allow_delegation=True,
instruments=[scrape_tool, search_tool]
)
Assigning the Duties:
Now let’s outline the duties.
Activity 1: Fetch At this time’s Gold Value
The Fetch At this time’s Gold Value Activity is liable for retrieving real-time gold costs in India from varied world sources. It gives an in depth report that features historic comparisons, regional value variations, and present market charges.
# Activity for Knowledge Analyst Agent: Analyze Market Knowledge
fetch_todays_gold_price = Activity(
description="Scrape the most recent 24K gold value in India from {url} and analyze macroeconomic tendencies affecting value actions.",
expected_output="At this time's gold value and key macroeconomic tendencies influencing its motion.",
agent=gold_price_analyst_agent,
)
Activity 2: Gold Value Predictor
The Gold Value Predictor Activity leverages historic information, macroeconomic indicators, and machine studying fashions to forecast gold costs for various timeframes—subsequent day, subsequent week, subsequent month, and subsequent 12 months. The output is an in depth report with future value predictions, enabling buyers and monetary analysts to plan their methods with larger confidence.
gold_price_predictor = Activity(
description=(
"Collect gold value information for the previous 2 weeks and predict day by day actions additionally give the sources from the place you're taking the information. Point out the date and in addition the supply of information taken"
"Solely search for final 3 days information whereas making prediction for any date. Validate every day's prediction in opposition to precise values, bettering accuracy iteratively."
"Do not look on precise worth for every day earlier than making prediction."
),
expected_output="An in depth report on prediction accuracy over the previous 2 weeks and tomorrow's anticipated gold value motion.",
agent=gold_price_predictor_agent,
)
Step 4: Creating the Crew
The Gold Value Predictor Crew is a structured AI system that brings collectively all of the brokers. These brokers work collaboratively to trace real-time gold costs, analyze market influences, and predict future tendencies. Utilizing the o3-mini mannequin with a hierarchical course of, the crew ensures an environment friendly workflow for gathering information, figuring out fluctuations, and producing gold value forecasts.
gold_price_predictor_crew = Crew(
brokers=[gold_price_analyst_agent, gold_price_predictor_agent],
duties=[fetch_todays_gold_price, gold_price_predictor],
manager_llm=ChatOpenAI(mannequin="o3-mini-2025-01-31", temperature=0.3),
course of=Course of.sequential,
verbose=True
)
Step 5: Kickoff the Crew
The Gold Value Predictor Crew is initiated utilizing the kickoff perform with particular inputs. This triggers the collaborative workflow, the place every agent executes its assigned activity. The ultimate result’s a well-structured report, offering real-time costs, market insights, and future value predictions to help buyers in making knowledgeable selections.
inputs = {"Question": "What would be the gold value motion in India for the subsequent day?",
"url": "https://www.goodreturns.in/gold-rates/"}
outcome = gold_price_predictor_crew.kickoff(inputs=inputs)
Output
This can assist us current the output in a markdown(.md) format.
from IPython.show import Markdown
markdown_content = outcome.uncooked
show(Markdown(markdown_content))
![Price prediction agent with o3-mini](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/output-1-2.webp)
![Price prediction agent with o3-mini](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/output2-2.webp)
![Price prediction agent with o3-mini](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/output3-1.webp)
![14-days 24-karat gold price prediction](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/output4-1.webp)
![14-days 24-karat gold price prediction](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/output5-1.webp)
![gold rate output](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/output6-1.webp)
![price prediction](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/output7-1.webp)
![o3-mini iterative improvement](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/output8.webp)
![24-karat gold price](https://cdn.analyticsvidhya.com/wp-content/uploads/2025/02/output9.webp)
Warning!
As you may see within the output, the agent makes its predictions primarily based on the vast majority of the outcomes of the earlier days. Its just like how we people guess the subsequent day’s value primarily based on whether or not the value has been going up or down off late. This isn’t actually correct and shouldn’t be thought of a strong value prediction software. There are different machine studying fashions like ARIMA, LSTM, and so forth. that possibly extra dependable on this case.
Therefore, this evaluation ought to solely be thought of as an indication to indicate how an agent for this activity might work, and extra importantly, to discover ways to construct an agent utilizing o3-mini. Subsequently, don’t take it as monetary recommendation. Monetary markets are unpredictable, and buying and selling them with out correct due diligence is dangerous. All the time conduct your personal analysis and seek the advice of a monetary skilled earlier than making funding selections.
Conclusion
On this article, we’ve discovered the best way to construct a gold prediction agent utilizing o3-mini, a quick and environment friendly AI mannequin. o3-mini is a light-weight but highly effective software for analyzing market tendencies, making it ideally suited for forecasting-related duties. Its affordability and effectivity make it an important selection for builders seeking to combine AI into their workflows and methods.
As gold and e-gold investments develop in recognition, having an AI-driven prediction agent may also help establish worthwhile alternatives, cut back dangers, and enhance decision-making. By analyzing tendencies, the agent streamlines market analysis and gives well timed insights. Nonetheless, it’s essential to notice that this basic-level agent shouldn’t be solely relied upon for funding selections. All the time complement AI insights with complete market evaluation {and professional} steerage.
Be taught all about OpenAI’s o3-mini on this complete course by Analytics Vidhya. Discover its core options and strengths and learn how it performs on varied duties by sensible hands-on workouts.
Regularly Requested Questions
A. o3-mini is a compact, environment friendly AI mannequin designed to ship sturdy efficiency whereas requiring fewer computational assets. It’s appropriate for a variety of purposes, together with coding, conversational AI, and monetary forecasting, providing a steadiness between velocity and accuracy.
A. o3-mini affords a extra environment friendly and cost-effective different to bigger fashions. Whereas it might not match their efficiency in sure advanced duties, it excels in velocity, effectivity, and affordability, making it ideally suited for real-time purposes with decrease useful resource necessities.
A. Sure, the o3-mini is extremely customizable. You’ll be able to regulate its configuration, fine-tune it for particular duties, and combine it with exterior information sources to boost its performance. Whether or not it’s for gold prediction or different monetary duties, o3-mini will be tailor-made to fulfill your wants.
A. o3-mini’s accuracy is determined by the complexity of the duty and the standard of the information fed to it. For easier duties, it will probably present moderately correct predictions, however for extra intricate evaluation, bigger fashions could also be wanted for improved precision.
A. The gold prediction agent is a useful software, but it surely shouldn’t be relied upon as the only real decision-making useful resource. All the time mix the insights generated by the agent with your personal analysis {and professional} monetary recommendation earlier than making any funding selections.