Skip to content

Conversation

@songofhawk
Copy link

Purpose

Add proxy setting to the Claude client, the user may has no right to connect claude.ai direct directly, but can do by a proxy. So this PR add an optional parameter to init funtion of Client class, which expect a dict to specify proxies for all protocals. The format of proxy parametr is same as requests lib.

Usage

import json
import os

from claude_api import Client

cookie = os.environ.get('cookie')
if not cookie:
    raise Exception('Please set the cookie environment variable')
print(f'cookie:{cookie}')

claude_api = Client(cookie, proxies={
   'http': 'http://proxy.example.com:8080',
   'https': 'http://secureproxy.example.com:8090',
})

prompt = "Please give me an interesting python code snippet within 5 lines."
conversation = claude_api.create_new_chat()
conversation_id = conversation['uuid']

response = claude_api.send_message(prompt, conversation_id)
print(response)

@jiacai2050
Copy link

@KoushikNavuluri Could you review this PR, this is really useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants