File size: 593 Bytes
09d85ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from flask import Flask, request, jsonify
import requests

app = Flask(__name__)

@app.route('/proxy/anthropic', methods=['POST'])
def proxy():
    api_key = request.headers.get('x-api-key')
    
    response = requests.post(
        'https://api.anthropic.com/v1/messages',
        headers={
            'Content-Type': 'application/json',
            'x-api-key': api_key,
            'anthropic-version': '2024-01-01'
        },
        json=request.json
    )
    
    return jsonify(response.json()), response.status_code

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=7860)