You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: api-reference/sdk/python.mdx
+34-1Lines changed: 34 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,8 +101,38 @@ async def main():
101
101
asyncio.run(main())
102
102
```
103
103
104
+
## Using a Custom httpx Client
104
105
105
-
### Adding Trace ID or Metadata
106
+
If you need to customize HTTP networking—for example, to disable SSL verification due to VPNs like Zscaler or to use custom proxies—you can pass your own `httpx.Client` to the Portkey SDK.
107
+
108
+
<Warning>Disabling SSL certificate verification is insecure and should only be used for debugging or in trusted internal environments. Never use this in production.</Warning>
109
+
110
+
**Example: Disable SSL Verification**
111
+
```python
112
+
import httpx
113
+
from portkey_ai import Portkey
114
+
115
+
# Create an httpx client with SSL verification disabled
116
+
custom_client = httpx.Client(verify=False)
117
+
118
+
portkey = Portkey(
119
+
api_key="your_api_key_here",
120
+
virtual_key="your_virtual_key_here",
121
+
http_client=custom_client
122
+
)
123
+
124
+
response = portkey.chat.completions.create(
125
+
messages=[{"role": "user", "content": "Hello!"}],
126
+
model="gpt-4o"
127
+
)
128
+
print(response)
129
+
```
130
+
131
+
- You can use any `httpx.Client` options (e.g., for proxies, timeouts, custom headers).
132
+
- For async usage, pass an `httpx.AsyncClient` to `AsyncPortkey`.
133
+
- See [OpenAI Python SDK: Configuring the HTTP client](https://github.com/openai/openai-python#configuring-the-http-client) for more examples and best practices.
134
+
135
+
## Adding Trace ID or Metadata
106
136
107
137
You can choose to override the configuration in individual requests as well and send trace id or metadata along with each request.
<Accordiontitle="Can I use this SDK with OpenAI-compatible code?">
157
187
Yes! Portkey’s Python SDK is OpenAI-compatible. You can also use any OpenAI-compatible library by pointing it to the Portkey API endpoint and using your Portkey API key.
158
188
</Accordion>
189
+
<Accordiontitle="How do I fix CERTIFICATE_VERIFY_FAILED or SSL errors?">
190
+
If you are behind a VPN (like Zscaler) or a corporate proxy and see SSL/certificate errors, you can pass a custom `httpx.Client` to the Portkey SDK with SSL verification disabled. See the docs above for an example. **Warning:** Disabling SSL verification is insecure—only use this as a last resort or for debugging.
191
+
</Accordion>
159
192
<Accordiontitle="Where can I find more examples?">
160
193
Check out our integration docs [here](/integrations/ecosystem).
0 commit comments