ProxAI as your AI friend. 🏆 Learn with Google Colab!

TL;DR: Stop moving one AI agent to another to get the required output. Learn how to use ProxAI with Google Colab and how easy it is.
Introduction
In this blog, we are going to learn how easy it is to implement ProxAI and verify output with multiple AI models simultaneously. Let’s learn it with a simple example of finding roots of a quadratic equation.
For more examples visit Google Colab documentation page
Let’s start by first installing ProxAI. Use your usual pip command and ready set go 🚀
Installation 💻
First, let’s open a new notebook file in Google Colab from: https://colab.google/
We need to install ProxAI to this notebook environment. Google Colab lets you run shell commands with the ”!” prefix. Install the ProxAI package to your running environment:
Cell Value:
!pip install proxaiCell Output: It should display the packages that are loaded as follows.
Collecting proxai
Downloading proxai-0.2.6-py3-none-any.whl.metadata (5.4 kB)
Collecting anthropic<0.22.0,>=0.21.3 (from proxai)......⚓ Load your ProxAI
Simply import ProxAI as you would other packages in Python.
Cell Value:
import proxai as px🔑 API Key Management
ProxAI works with various AI providers. You’ll need to add your API keys as secrets in Google Colab. This is the safest way to handle them.
- Click on the 🔑 icon (Secrets) in the left sidebar of Colab.
- Add your API keys with the names ProxAI expects (e.g.,
OPENAI_API_KEY,GEMINI_API_KEY,PROXDASH_API_KEY, etc.). Refer to the Provider Integrations documentation for the full list of environment keys.
Run the following cell to load your API keys from Colab secrets into the environment.
Important Security Note: Never directly add API key values as string variables inside the Colab cells. Even after deletion, they can be retrieved from the Colab history.
Cell Value:
import os
from google.colab import userdata
API_KEY_LIST = [
'GEMINI_API_KEY',
'OPENAI_API_KEY',
]
for api_key in API_KEY_LIST:
try:
os.environ[api_key] = userdata.get(api_key)
except:
continueLet’s find out if our AI agents are properly added or not by listing providers!
Cell Value:
providers = px.models.list_providers()
for provider in providers:
print(provider)Cell Output:
gemini
openaiLoaded 📢 two AI 🤖 agents: Gemini and OpenAI
Next task would be to check how many models each of these AI agents provides. So, simply list these models and print them!
Cell Value:
provider_models = px.models.list_models()
print(len(provider_models))
for provider_model in provider_models:
print(provider_model)Cell Output:
23
(gemini, gemini-1.5-flash)
(gemini, gemini-1.5-flash-8b)
(gemini, gemini-2.0-flash)
(gemini, gemini-2.0-flash-lite)
(gemini, gemini-2.5-flash)
(gemini, gemini-2.5-flash-lite-preview-06-17)
(gemini, gemini-2.5-pro)
(openai, chatgpt-4o-latest)
(openai, gpt-3.5-turbo)
(openai, gpt-4)
(openai, gpt-4-turbo)
(openai, gpt-4.1)
(openai, gpt-4.1-mini)
(openai, gpt-4.1-nano)
(openai, gpt-4o)
(openai, gpt-4o-mini)
(openai, gpt-4o-mini-search-preview)
(openai, gpt-4o-search-preview)
(openai, o1)
(openai, o1-mini)
(openai, o3)
(openai, o3-mini)
(openai, o4-mini)Loaded 📢 23 AI models 🔸 provided by AI agents
With ProxAI we can work with these 23 AI models simultaneously. Simply the choice is yours! 🤙
- Use them all at once
- Use one model at a time
- Choose whichever suits your interest and budget
Example: Working with gpt-3.5-turbo provided by OpenAI
Cell Input:
provider_model = provider_models[8]
answer = px.generate_text(
prompt='Calculate the roots of x^2+2x+5 =0 ?',
provider_model=provider_model)
print(f'{provider_model}: {answer}')Cell Output:
(openai, gpt-3.5-turbo): The roots of the quadratic equation x^2+2x+5=0 can be calculated using the quadratic formula:
x = (-b ± √(b^2 - 4ac)) / 2a
In this equation, a=1, b=2, and c=5.
Plugging these values into the formula, we get:
x = (-2 ± √(2^2 - 4*1*5)) / 2*1
x = (-2 ± √(4 - 20)) / 2
x = (-2 ± √(-16)) / 2
x = (-2 ± 4i) / 2
Therefore, the roots of the equation x^2+2x+5=0 are complex numbers:
x1 = -1 - 2i
x2 = -1 + 2iExample: Working with gemini-2.0-flash provided by Gemini
Cell Input:
provider_model = provider_models[2]
answer = px.generate_text(
prompt='Calculate the roots of x^2+2x+5 =0 ?',
provider_model=provider_model)
print(f'{provider_model}: {answer}')Cell Output:
(gemini, gemini-2.0-flash): To find the roots of the quadratic equation $x^2 + 2x + 5 = 0$, we can use the quadratic formula:
$$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$
where $a$, $b$, and $c$ are the coefficients of the quadratic equation $ax^2 + bx + c = 0$. In this case, we have $a = 1$, $b = 2$, and $c = 5$.
Substituting these values into the quadratic formula, we get:
$$x = \frac{-2 \pm \sqrt{2^2 - 4(1)(5)}}{2(1)}$$
$$x = \frac{-2 \pm \sqrt{4 - 20}}{2}$$
$$x = \frac{-2 \pm \sqrt{-16}}{2}$$
Since the discriminant is negative, the roots will be complex. We can rewrite $\sqrt{-16}$ as $4i$, where $i = \sqrt{-1}$.
$$x = \frac{-2 \pm 4i}{2}$$
$$x = \frac{-2}{2} \pm \frac{4i}{2}$$
$$x = -1 \pm 2i$$
So the roots are $x = -1 + 2i$ and $x = -1 - 2i$.
Final Answer: The final answer is $\boxed{-1+2i, -1-2i}$🔚 Final thoughts
-
Just Start Coding: Don’t wait, open a Google Colab notebook from https://colab.google/ and start your experiments.
-
Compare Models: Switch between different provider models and observe which one is the best for your case.
-
Unlock ProxAI’s full power: Go beyond the basics of ProxAI, and unlock the power of caching, error handling, model hot loading and many more from proxai.co/proxai-docs