This repository contains code examples for building agentic AI workflows using OpenRouter API, which provides access to multiple AI models (OpenAI, Anthropic, Google, etc.) through a single, consistent interface.
- Access models from multiple providers through one unified API
- Compare responses from different AI models
- Build multi-step reasoning agents that break down complex tasks
- Example workflow for research and recommendation tasks
- Python 3.8 or higher
- OpenRouter account (sign up at openrouter.ai)
- Clone this repository:
git clone https://github.com/your-username/agentic-ai-workflow
cd agentic-ai-workflow
- Create a virtual environment:
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Create a
.env
file with your API keys:
OPENROUTER_API_KEY=your_openrouter_api_key_here
YOUR_SITE_URL=https://yourdomain.com
YOUR_SITE_NAME=Your App Name
Test your OpenRouter API connection:
python basic_setup.py
Compare responses from different AI models:
python model_comparison.py
Execute a multi-step reasoning workflow:
python agent_example.py
basic_setup.py
- Basic OpenRouter API client setupmodel_comparison.py
- Compare responses from different modelsagent_example.py
- Complete agentic workflow implementationrequirements.txt
- Project dependencies
- Add vector database for long-term memory
- Enable external tools (web search, calculators, etc.)
- Implement model routing for cost optimization
- Add retry logic and better error handling
- Implement user feedback loops
For a detailed tutorial on building agentic AI workflows with OpenRouter API, check out the article:
- Building Your First Agentic AI Workflow with OpenRouter API by Allan Niñal