Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: proxies argument for Client class initializing. #73

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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