Transform any web-based AI model into an OpenRouter-compatible API that works with Cline, Continue, Cursor, and other OpenAI-compatible tools.
# Virtual environment and dependencies are ready
uv --version # β
Working# Start mock server (no Chrome required)
uv run python test_server.py
# Server runs on: http://localhost:8001# Start real server (requires Chrome)
uv run python openrouter_server.py
# Server runs on: http://localhost:8000- Open Cline settings
- Configure:
- Provider: OpenAI Compatible
- Base URL:
http://localhost:8001/v1(mock) orhttp://localhost:8000/v1(real) - API Key:
dummy-key - Model:
google/gemini-pro
Edit ~/.continue/config.json:
{
"models": [
{
"title": "Gemini Pro (Web)",
"provider": "openai",
"model": "google/gemini-pro",
"apiBase": "http://localhost:8001/v1",
"apiKey": "dummy-key"
}
]
}- Settings β Models β Add Custom Model
- Configure:
- Provider: OpenAI Compatible
- Base URL:
http://localhost:8001/v1 - Model:
google/gemini-pro - API Key:
dummy-key
google/gemini-pro- Google's Gemini Pro via AI Studiogoogle/gemini-pro-vision- Gemini Pro with vision capabilities
# In terminal 1:
uv run python test_server.py
# In terminal 2:
uv run python test_mock_client.py# In terminal 1:
uv run python openrouter_server.py
# In terminal 2:
uv run python client_test.pyuv run python quick_test.pyGET /v1/models- List available modelsPOST /v1/chat/completions- Chat completions (streaming & non-streaming)GET /health- Health check
import openai
client = openai.OpenAI(
api_key="dummy-key",
base_url="http://localhost:8001/v1" # or 8000 for real
)
response = client.chat.completions.create(
model="google/gemini-pro",
messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)curl -X POST http://localhost:8001/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemini-pro",
"messages": [{"role": "user", "content": "Hello!"}]
}'To add support for other web-based models:
- Create LLM wrapper (similar to
GoogleAIStudioLLM) - Add to model registry in server
- Update
get_llm_instance()function
Example for ChatGPT:
# Create chatgpt_llm.py
class ChatGPTWebLLM(LLM):
# Implementation for chat.openai.com
pass
# Add to openrouter_server.py
AVAILABLE_MODELS["openai/gpt-4-web"] = {...}- β Should work out of the box
- Check port 8001 is available
- Install Chrome browser
- Check Google AI Studio login
- Verify port 8000 is available
- Check firewall settings
- Ensure server is running
- Verify correct base URL
- Check API key (use "dummy-key")
- Confirm model name matches exactly
βββ google_ai_studio_llm.py # Real Google AI Studio wrapper
βββ mock_llm.py # Mock LLM for testing
βββ openrouter_server.py # Real server (port 8000)
βββ test_server.py # Mock server (port 8001)
βββ client_test.py # Test real server
βββ test_mock_client.py # Test mock server
βββ quick_test.py # Quick validation
βββ README.md # This file
- OpenRouter-compatible API for any web-based AI model
- Mock testing environment that works without Chrome
- Real Google AI Studio integration via Selenium
- Full streaming support for real-time responses
- Easy tool integration with Cline, Continue, Cursor, etc.
- Extensible architecture for adding more models
Your setup is complete and tested. You can now:
- Use the mock server for development and testing
- Add Chrome and use the real Google AI Studio integration
- Configure your favorite coding tools to use your local OpenRouter
- Extend to other web-based models as needed
Happy coding! π