Skip to content

Add option for proxying SDK requests to API and sandbox#695

Merged
ValentaTomas merged 6 commits intomainfrom
proxy
Apr 18, 2025
Merged

Add option for proxying SDK requests to API and sandbox#695
ValentaTomas merged 6 commits intomainfrom
proxy

Conversation

@ValentaTomas
Copy link
Copy Markdown
Member

@ValentaTomas ValentaTomas commented Apr 18, 2025

PR that allows you to pass proxy (of the type ProxyTypes) when calling methods in the SDK that send requests. Also, if you pass proxy when creating a sandbox, all the sandbox requests (called on the Sandbox/AsyncSandbox instance) will automatically use the same proxy.

The PR also contains a small bugfix—adding missing passing of limits and passing these directly instead of through transport to be able to pass the proxy parameter properly.

This change should also be compatible with the code interpreter—it uses the client transport, which uses the passed proxy if there is any.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 18, 2025

🦋 Changeset detected

Latest commit: 9fd8c87

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@e2b/python-sdk Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ValentaTomas ValentaTomas added feature New feature or request sdk Improvements or additions to SDKs labels Apr 18, 2025
@0div
Copy link
Copy Markdown
Contributor

0div commented Apr 18, 2025

at a glance this looks good, it's nice that we can leverage the httpx client and its ProxyTypes

@ValentaTomas ValentaTomas marked this pull request as ready for review April 18, 2025 21:20
@ValentaTomas ValentaTomas assigned 0div and unassigned mishushakov Apr 18, 2025
@ValentaTomas ValentaTomas requested a review from 0div April 18, 2025 21:26
Copy link
Copy Markdown
Contributor

@0div 0div left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all python-sdk tests pass, i realize it's hard to test the proxy itself but have you tested manually?

:param debug: Enable debug mode, all requested are then sent to localhost
:param request_timeout: Timeout for the request in **seconds**
:param headers: Additional headers to send with the request
:param proxy: Proxy to use for the request
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd prob specify the type httpx.ProxyType here as the SDK ref won't show it explicitly

@ValentaTomas ValentaTomas merged commit 74ff53c into main Apr 18, 2025
5 checks passed
@ValentaTomas ValentaTomas deleted the proxy branch April 18, 2025 22:12
@0div 0div mentioned this pull request Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request sdk Improvements or additions to SDKs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants