If you're getting started with AI, one of the biggest challenges is cost and flexibility.
Most tutorials lock you into a single provider. But in real-world projects, you should be able to:
Switch models easily π
Compare outputs βοΈ
Use free providers when possible πΈ
In this blog, Iβll show a simple way to use multiple AI providers in one setup.
π‘ Learn AI Without Spending Money
One of the biggest blockers for developers getting into AI is cost.
Not everyone can afford paid APIs β and thatβs completely fine.
Thatβs why tools like:
π§ Cerebras (free-tier models)
π Open/free LLM providers
π§ͺ Community-hosted APIs
are game changers.
pip install openai
Generate API Keys
OpenAI β https://platform.openai.com/
Cerebras β https://cloud.cerebras.ai/
ArliAI β https://www.arliai.com/account
Beginners can use Jupyter Notebook to try the following code while others can follow in their own code editors.
π Set API Keys
import os
os.environ['ARLIAI_API_KEY'] = "xxx"
os.environ['CEREBRAS_API_KEY'] = "yyy"
os.environ['OPENAI_API_KEY'] = "zzz"
βοΈ Configure Multiple LLM Providers
# Set LLM providers to change models easily
llm_providers = {
"arliai": {
"api_key": os.getenv("ARLIAI_API_KEY"),
"base_url": "https://api.arliai.com/v1",
"model": "Llama-3.3-70B-ArliAI-RPMax-v3",
},
"cerebras": {
"api_key": os.getenv("CEREBRAS_API_KEY"),
"base_url": "https://api.cerebras.ai/v1",
"model": "llama3.1-8b",
},
"openai": {
"api_key": os.getenv("OPENAI_API_KEY"),
"base_url": "https://api.openai.com/v1",
"model": "gpt-4o-mini",
}
}
π§ Helper Function to Switch Providers
from openai import OpenAI
def set_llm(provider_name):
provider = llm_providers[provider_name]
client = OpenAI(
api_key=provider["api_key"],
base_url=provider["base_url"]
)
return client
π§ͺ Test with Cerebras (Free Model)
llm = set_llm('cerebras')
name = llm.invoke("I want to open a restaurant for Indian food. Suggest a fancy name for this.")
print(name.content)
β Sample Output (Cerebras)
Here are some fancy name suggestions for an Indian restaurant:
1. **Maharaja's Mosaic**: This name evokes the grandeur and richness of Indian royalty, while also hinting at the diverse flavors and cuisines that Indian food has to offer.
2. **Tandoori Nights**: This name captures the essence of Indian food, with the tandoor oven being a staple of Indian cuisine. It also has a romantic and exotic connotation.
3. **Kashmiri Kitchen**: This name suggests a high-end, sophisticated dining experience, with a focus on the rich culinary traditions of the Kashmir region.
4. **Dhaba Royale**: A dhaba is a type of Indian restaurant, but by adding "Royale" to the name, you're implying a luxurious and upscale dining experience.
5. **Saffron & Spice**: Saffron is a highly prized spice in Indian cuisine, and by combining it with "Spice", you're highlighting the complex and aromatic flavors that Indian food is known for.
6. **Mumbai Magic**: This name captures the energy and vibrancy of India's largest city, while also hinting at the magic and wonder of Indian cuisine.
7. **Garam Gourmet**: "Garam" means "hot" in Hindi, and "Gourmet" implies a high-end dining experience. This name suggests a restaurant that serves spicy, flavorful food in a sophisticated setting.
8. **Rajasthani Rhapsody**: This name suggests a restaurant that serves the rich and regal cuisine of Rajasthan, with a focus on the region's unique flavors and traditions.
9. **Spice Route Bazaar**: This name captures the essence of Indian cuisine, with its complex blend of spices and flavors. The word "Bazaar" also implies a lively and vibrant atmosphere.
10. **Ayurvedic Eats**: This name suggests a restaurant that serves food that is not only delicious but also healthy and nourishing, with a focus on the principles of Ayurvedic medicine.
I hope these suggestions help inspire you to find the perfect name for your Indian restaurant!
π Test the Same with OpenAI
llm = set_llm('openai')
name = llm.invoke("I want to open a restaurant for Indian food. Suggest a fancy name for this.")
print(name.content)
β Sample Output (OpenAI)
Here are some fancy name suggestions for your Indian restaurant:
1. **Saffron & Spice**
2. **Curry Couture**
3. **The Royal Masala**
4. **Tandoori Treasures**
5. **Noble Naan**
6. **Mystic Flavors**
7. **Bollywood Bites**
8. **Spice Symphony**
9. **Heritage Haveli**
10. **Kashmiri Delight**
Feel free to mix and match or modify any of these names to better suit your vision!
π Why This Approach Matters
This is not just a simple example β itβs a real-world pattern.
With this setup, you can:
π Switch between providers instantly
πΈ Use free models like Cerebras
β‘ Compare outputs across models
π§ͺ Experiment without vendor lock-in
π§βπ» For Developers
Donβt just read about AI β build with it.
Start small:
- Try different prompts
- Compare model outputs
With the right setup, any developer can build AI-powered applications using both free and paid models.
So:
- Try multiple providers
- Experiment freely
- Build something useful
In our next blog, weβll build helper functions using LangChain to make this setup even more powerful.
Top comments (0)