uezo / aiproxy

🦉AIProxy is a reverse proxy for ChatGPT API that provides monitoring, logging, and filtering requests and responses.
Apache License 2.0
38 stars 1 forks source link

Add support for Anthropic Claude 3 #26

Closed uezo closed 3 months ago

uezo commented 3 months ago

Server

Add route for ClaudeProxy to FastAPI app.

from aiproxy.anthropic_claude import ClaudeProxy
claude_proxy = ClaudeProxy(
    api_key="YOUR_ANTHROPIC_API_KEY",
    access_logger_queue=worker.queue_client
)
claude_proxy.add_route(app, "/claude/v1/messages")

Client

Just change the endpoint url.

request = httpx.Request(
    method="POST",
    url="http://127.0.0.1:8000/claude/v1/messages",
    headers={
        "x-api-key": "dummy",
        "anthropic-version": "2023-06-01"
    },
    json=request_json
)