|
| 1 | +# Portkey |
| 2 | + |
| 3 | +[Portkey](https://portkey.ai/docs/introduction/what-is-portkey) is an enterprise-grade LLM gateway running on-prem: |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +Broadly it facilitates: |
| 8 | +- **Route requests** via configurations that can allow for fallbacks, load balance, etc |
| 9 | +- **Observability** via the control pane that displays your usage statistics and logs. You can retrive your logs via an API. |
| 10 | +- **Prompt management** via the prompt playground. You can compare the respone for a prompt across multiple LLMs, collaborate with your team and export your prompts. |
| 11 | +- **Guardrails** usage by allowing you to define them or integrate with third party guardrails. |
| 12 | +- **Agentic workflows** by integrating with various agentic frameworks like langchain, llamaindex, etc. |
| 13 | +- **Security & Governance** by allowing you to set budget and rate limits on the API keys created for your workspace |
| 14 | + |
| 15 | +:::tip[Gateway URL] |
| 16 | +Whenever you instantiate a Portkey client, the `base_url` must be set to `base_url="https://ai-gateway.apps.cloud.rt.nyu.edu/v1/"`. If you miss this parameter you would be connecting to the vendor's SaaS platform and NYU provisioned virtual keys will not work. |
| 17 | +::: |
| 18 | + |
| 19 | +## Onboarding |
| 20 | +Send an email to `[email protected]` to start the onboarding process. |
| 21 | + |
| 22 | +## Getting started with Portkey |
| 23 | +As part of the onboarding process, you would have received an invite which gives you access to a workspace. We will also add virtual keys for LLMs to your workspace as part of the onboarding process. Once you've accepted it, head over to `https://app.portkey.ai/` and select the sign-in with Single Sign-On option and proceed with your NYU email address. |
| 24 | + |
| 25 | +:::danger[Access to Portkey is only permitted via NYU VPN] |
| 26 | +You need to be connected to the NYU VPN to access the Portkey LLM gateway. If you are not, your requests will timeout and result in connection errors. |
| 27 | +::: |
| 28 | + |
| 29 | +You will now be able to create an API key for yourself by access the `API Keys` item on the left sidebar. With an API key and a virtual key at your disposal, you can now run the following script: |
| 30 | +```python |
| 31 | +from portkey_ai import Portkey |
| 32 | + |
| 33 | +portkey = Portkey( |
| 34 | + base_url="https://ai-gateway.apps.cloud.rt.nyu.edu/v1/", |
| 35 | + api_key="", # Replace with your Portkey API key |
| 36 | + virtual_key="", # Replace with your virtual key for Google |
| 37 | +) |
| 38 | + |
| 39 | +completion = portkey.chat.completions.create( |
| 40 | + messages=[ |
| 41 | + {"role": "system", "content": "You are not a helpful assistant"}, |
| 42 | + {"role": "user", "content": "Say this is a test"}, |
| 43 | + ], |
| 44 | + model="gemini-2.0-flash-lite-preview-02-05", |
| 45 | +) |
| 46 | + |
| 47 | +print(completion) |
| 48 | +``` |
| 49 | + |
| 50 | +Once the script is executed, you can head back to `app.portkey.ai` to view the logs for the call! |
0 commit comments