Claude to ChatGPT: Making AI API Integration Seamless
The "Claude to ChatGPT" project bridges the gap between different AI platforms, allowing users to interact with Anthropic's Claude model using the familiar OpenAI Chat API format. This seamless integration not only simplifies the process but also enhances the flexibility of deploying AI models.
Key Features
- Effortless API Switching: Users can call the Claude API just like they would with the OpenAI ChatGPT API, streamlining the integration process.
- Streaming Support: The project supports streaming responses for real-time interaction.
- Model Compatibility: Compatible with
claude-instant-1
andclaude-2
models. - Multiple Deployment Options: Deploy the service using Cloudflare Workers or Docker for flexibility in various environments.
Getting Started
Implementing this project can be done using two primary methods:
Deployment Options
Cloudflare Workers
Deploying with Cloudflare Workers eliminates the need for a dedicated server:
- Create a Cloudflare Worker.
- Copy and paste the provided code into the Cloudflare Worker "Quick Edit" Editor.
- Save and deploy your worker.
- Optionally, set a custom domain for your Worker.
Cloudflare Workers offer up to 100,000 requests a day for free. If you anticipate exceeding this, consider deploying with Docker.
Docker Deployment
For those preferring a local or more traditional deployment setup, Docker provides a robust solution:
docker run -p 8000:8000 wtzeng/claude-to-chatgpt:latest
Or, use Docker Compose for a streamlined approach:
docker-compose up
Once deployed, the API is accessible at http://localhost:8000
, with the endpoint /v1/chat/completions
.
How It Works
When using this API, specifying the model as gpt-3.5-turbo
or gpt-3.5-turbo-0613
will default to claude-instant-1
. Any other input will use claude-2
. This model selection allows users to easily switch models without changing their code.
Graphical User Interface (GUI)
For enhanced interaction, users might consider GUI tools like:
Command Line Interface (CLI)
For users who prefer command-line interactions, here’s a quick usage example:
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $CLAUDE_API_KEY" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "Hello!"}]
}'
Conversion Specifics
The project's core functionality revolves around converting API requests. The Claude Completion API uses an endpoint /v1/complete
to gather AI responses based on various parameters such as prompt and model type. This is then formatted to match the OpenAI Chat API response style, ensuring compatibility and ease of use.
Licensing
The project is available under the MIT License, allowing users flexibility in using and modifying the software as needed.
In summary, the Claude to ChatGPT project offers an innovative solution for developers looking to leverage the capabilities of multiple AI models without the hassle of dealing with different API protocols. By providing an easy-to-use interface and multiple deployment options, it stands as a valuable tool for seamless AI integration.