A Flask API that enables direct comparison between OpenAI's ChatGPT and Anthropic's Claude responses through their APIs. Compare different model versions and generations side by side.
- Single endpoint to query both AI models simultaneously
- Configurable model selection for both providers
- JSON-based request/response format
Compare responses between ChatGPT and Claude models.
{
"prompt": "What is the meaning of life?",
"chatgpt_model": "gpt-4", // optional, defaults to "gpt-4o-mini"
"claude_model": "claude-3-sonnet-20240229" // optional, defaults to "claude-3-7-sonnet-20250219"
}
{
"prompt": "What is the meaning of life?",
"chatgpt_response": "The meaning of life is...",
"claude_response": "From a philosophical perspective..."
}
{
"prompt": "act as python developer, how to do a hello world in python. Keep it short",
"chatgpt_response": "```python\nprint(\"Hello, world!\")\n```",
"claude_response": "```python\nprint(\"Hello, World!\")\n```"
}
{
"prompt": "act as python developer, how to do a hello world in python. Keep it short",
"chatgpt_response": "To print \"Hello, World!\" in Python, simply use the `print` function. Here's the code:\n\n```python\nprint(\"Hello, World!\")\n```\n\nRun this code in your Python environment, and it will display the message.",
"claude_response": "# Hello World in Python\n\n```python\nprint(\"Hello, World!\")\n```\n\nThat's it! Just save this in a file with `.py` extension (e.g., `hello.py`) and run it with `python hello.py` from your command line."
}
-
OpenAI API Key
- Create an account at OpenAI Platform
- Generate an API key
- Minimum recommended balance: $5 USD
-
Anthropic API Key
- Create an account at Anthropic Console
- Generate an API key
- Minimum recommended balance: $5 USD
Create a .env
file in the project root:
openai_api_key=your-openai-key-here
anthropic_api_key=your-anthropic-key-here
pip install -r requirements.txt
Withing this repo you will find .vscode/launch.json
which enables you to run the app using the Run and Debug menu.
- Enable the following env variables
export FLASK_APP=app/main.py
export PYTHONPATH="${PYTHONPATH}:/path/to/AI-Model-Comparison-API"
- Run the app.
flask run
- GPT-4 Turbo
- GPT-4
- GPT-3.5 Turbo
- Full list of OpenAI models
- Check your model access
- Claude 3 Opus
- Claude 3 Sonnet
- Claude 2.1
- Full list of Anthropic models
Access your usage and credits:
- OpenAI: Usage Dashboard
- Anthropic: Console Dashboard
This is a weekend project created as my first exploration into AI APIs from a developer's perspective. The main goal is learning and understanding how to interact with different AI models programmatically. While functional, this project is:
- Built for educational purposes
- A learning experiment with AI APIs
- Not intended for production use
- Open to improvements and suggestions
- Created to compare different AI models' responses
Feel free to use this as a starting point for your own AI API exploration journey!