claudeflare-proxy
v1.0.1
Published
OpenAI API proxy with internet search capabilities and conversation tracking
Maintainers
Readme
Claudeflare Proxy
A lightweight proxy server for OpenAI's API with optional internet search capabilities via Tavily integration.
🤔 Are you tired of Claude saying "I don't have access to real-time information" or going in circles trying to help you? Well, this proxy gives Claude (via OpenAI's API) the power to search the internet! No more "I should note that my knowledge cutoff is..." or watching Claude apologetically explain why it can't check current events. Now it can actually look things up instead of doing that thing where it rewrites the same response three different ways hoping one of them helps. You know what we're talking about. 🔄
Features
- 🔄 Drop-in OpenAI API Replacement - Compatible with existing OpenAI clients
- 🌐 Optional Internet Search - Enhance responses with real-time web data
- 📊 Conversation Tracking - Built-in dashboard to view conversation history and usage stats
- 🚀 Simple Setup - Environment-based configuration
- 📝 Flexible Endpoints - Simplified
/chatendpoint or full OpenAI compatibility - ⚡ Performance Optimized - Selective search enhancement based on query content
- 🎨 Real-time Dashboard - View conversations with live updates at
http://localhost:3456/ui/dashboard.html
Installation
npm install -g claudeflare-proxyQuick Start
- Configure environment variables
Create a .env file:
OPENAI_API_KEY=your_openai_api_key
# Optional: Enable internet search
TAVILY_API_KEY=your_tavily_api_key
# Optional: Configuration
DEFAULT_MODEL=gpt-4o
PORT=3456- Start the server
claudeflare- Make requests
curl -X POST http://localhost:3456/chat \
-H "Content-Type: application/json" \
-d '{"message": "What is the capital of France?"}'API Endpoints
/chat - Simplified Interface
curl -X POST http://localhost:3456/chat \
-H "Content-Type: application/json" \
-d '{"message": "Hello", "temperature": 0.7}'Options:
message- User message (string)model- Model to use (default: from .env)temperature- Creativity level 0-2 (default: 0.7)max_tokens- Response length limitsystem- System promptsearch- Force search on/off (boolean)format- Response format: "text" or "json"
/v1/chat/completions - OpenAI Compatible
Full compatibility with OpenAI's chat completions API.
Configuration
| Variable | Description | Default |
|----------|-------------|---------|
| OPENAI_API_KEY | OpenAI API key | Required |
| TAVILY_API_KEY | Tavily API key for search | Optional |
| DEFAULT_MODEL | Default model | gpt-4 |
| PORT | Server port | 3456 |
| LOG_LEVEL | Logging level | info |
| ENABLE_REQUEST_LOGGING | Log requests | true |
| FORCE_INTERNET_SEARCH | Force search for all models | false |
| INTERNET_CAPABLE_MODELS | Models that support search | gpt-4,gpt-4-turbo,gpt-4o,gpt-3.5-turbo |
Internet Search
Search is automatically triggered when:
- Tavily is configured
- Model supports internet capabilities
- Query contains keywords like: "latest", "current", "today", "news", etc.
Override with "search": true/false in your request.
Examples
Force Internet Search
curl -X POST http://localhost:3456/chat \
-H "Content-Type: application/json" \
-d '{"message": "What happened today?", "search": true}'Get JSON Response
curl -X POST http://localhost:3456/chat \
-H "Content-Type: application/json" \
-d '{"message": "Hello", "format": "json"}'Use Different Model
curl -X POST http://localhost:3456/chat \
-H "Content-Type: application/json" \
-d '{"message": "Hello", "model": "gpt-3.5-turbo"}'Using with Claude (Anthropic)
To get the best results when using Claudeflare with Claude, add these instructions to Claude's system prompt or project knowledge:
Recommended Claude Instructions
When making OpenAI API calls, use the local Claudeflare proxy at http://localhost:3456 instead of the default OpenAI endpoint. This proxy adds internet search capabilities.
Key endpoints:
- Simple chat: POST http://localhost:3456/chat
- OpenAI-compatible: POST http://localhost:3456/v1/chat/completions
For real-time information, add "search": true to enable web search:
{
"message": "What's the latest news about X?",
"search": true
}
The proxy automatically detects when searches would be helpful for queries about:
- Current events and news
- Recent developments
- Real-time information
- Specific dates/times
- Latest updates
Response format options:
- Default: Plain text response
- JSON: Add "format": "json" to get structured response with usage statsAdding to Claude Projects
- Create a new file in your Claude project called
claudeflare-config.md - Add the instructions above
- Claude will automatically use the proxy for OpenAI API calls
- The proxy's conversation tracking dashboard is available at http://localhost:3456/ui/dashboard.html
Development
git clone https://github.com/joedigiovanna/claudeflare-proxy.git
cd claudeflare-proxy
npm install
npm startAPI Reference
See CHAT-EXAMPLES.md for comprehensive API documentation and examples.
License
MIT
Author
Joseph DiGiovanna [email protected]
