Skip to content

Commit 7b4ba2e

Browse files
Merge pull request #340 from Portkey-AI/chore/update-gateway-to-other-api-page
Update Gateway to other endpoints page. Add SDK methods
2 parents bd7ba7a + bbca65e commit 7b4ba2e

File tree

2 files changed

+133
-26
lines changed

2 files changed

+133
-26
lines changed

api-reference/inference-api/gateway-for-other-apis.mdx

Lines changed: 130 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,18 @@ Portkey API has first-class support for monitoring and routing your requests to
1111

1212
**However**, there are still many endpoints like Cohere's `/rerank` or Deepgram's `/listen` that are uncommon or have niche use cases.
1313

14-
With the **Gateway to Other APIs** feature, you can route to any custom provider endpoint using Portkey (including the ones hosted on your private setups) and get **complete logging & monitoring** for all your requests.
14+
With the **Gateway to Other APIs** feature, you can route to any custom provider endpoint using Portkey (including the ones hosted on your private setups) and get **complete logging & monitoring** for all your requests.
15+
16+
## Supported HTTP Methods
17+
18+
<CardGroup cols={4}>
19+
<Card title="POST" color="#4CAF50" />
20+
<Card title="GET" color="#2196F3" />
21+
<Card title="PUT" color="#FF9800" />
22+
<Card title="DELETE" color="#F44336" />
23+
</CardGroup>
24+
25+
Both the REST API and Portkey SDKs (Python, NodeJS) support all of these HTTP methods.
1526

1627
# How to Integrate
1728

@@ -21,7 +32,7 @@ With the **Gateway to Other APIs** feature, you can route to any custom provider
2132

2233

2334
## 1. Get Portkey API Key
24-
Create or log in to your Portkey account. Grab your accounts API key from the [API Keys page](https://app.portkey.ai/api-keys).
35+
Create or log in to your Portkey account. Grab your account's API key from the ["API Keys" page](https://app.portkey.ai/api-keys).
2536

2637
## 2. Add Provider Details
2738

@@ -148,7 +159,8 @@ Construct your request URL:
148159
1. Portkey Gateway base URL remains same: `https://api.portkey.ai/v1`
149160
2. Append your custom endpoint at the end of the URL: `https://api.portkey.ai/v1/{provider-endpoint}`
150161

151-
```bash
162+
<CodeGroup>
163+
```bash POST
152164
curl --request POST \
153165
--url https://api.portkey.ai/v1/rerank \
154166
--header 'Content-Type: application/json' \
@@ -163,14 +175,43 @@ curl --request POST \
163175
]
164176
}'
165177
```
178+
179+
```bash GET
180+
curl --request GET \
181+
--url https://api.portkey.ai/v1/collections \
182+
--header 'Content-Type: application/json' \
183+
--header 'x-portkey-api-key: $PORTKEY_API_KEY' \
184+
--header 'x-portkey-virtual-key: $PROVIDER_VIRTUAL_KEY'
185+
```
186+
187+
```bash PUT
188+
curl --request PUT \
189+
--url https://api.portkey.ai/v1/collections/my-collection \
190+
--header 'Content-Type: application/json' \
191+
--header 'x-portkey-api-key: $PORTKEY_API_KEY' \
192+
--header 'x-portkey-virtual-key: $PROVIDER_VIRTUAL_KEY' \
193+
--data '{
194+
"metadata": {
195+
"description": "Updated collection description"
196+
}
197+
}'
198+
```
199+
200+
```bash DELETE
201+
curl --request DELETE \
202+
--url https://api.portkey.ai/v1/collections/my-collection \
203+
--header 'Content-Type: application/json' \
204+
--header 'x-portkey-api-key: $PORTKEY_API_KEY' \
205+
--header 'x-portkey-virtual-key: $PROVIDER_VIRTUAL_KEY'
206+
```
207+
</CodeGroup>
166208
</Tab>
167209

168210
<Tab title="Python SDK">
169-
<Info>The SDK supports the `POST` method currently.</Info>
170-
1. Instantiate your Portkey client
171-
2. Use the `.post(url, requestParams)` method to make requests:
211+
The SDK fully supports all HTTP methods: `POST`, `GET`, `PUT`, and `DELETE`.
172212

173-
```python
213+
<CodeGroup>
214+
```python POST
174215
from portkey_ai import Portkey
175216

176217
portkey = Portkey(
@@ -188,14 +229,52 @@ response = portkey.post(
188229
]
189230
)
190231
```
232+
233+
```python GET
234+
from portkey_ai import Portkey
235+
236+
portkey = Portkey(
237+
api_key="PORTKEY_API_KEY",
238+
virtual_key="PROVIDER_VIRTUAL_KEY"
239+
)
240+
241+
response = portkey.get('/collections')
242+
```
243+
244+
```python PUT
245+
from portkey_ai import Portkey
246+
247+
portkey = Portkey(
248+
api_key="PORTKEY_API_KEY",
249+
virtual_key="PROVIDER_VIRTUAL_KEY"
250+
)
251+
252+
response = portkey.put(
253+
'/collections/my-collection',
254+
metadata={
255+
"description": "Updated collection description"
256+
}
257+
)
258+
```
259+
260+
```python DELETE
261+
from portkey_ai import Portkey
262+
263+
portkey = Portkey(
264+
api_key="PORTKEY_API_KEY",
265+
virtual_key="PROVIDER_VIRTUAL_KEY"
266+
)
267+
268+
response = portkey.delete('/collections/my-collection')
269+
```
270+
</CodeGroup>
191271
</Tab>
192272

193273
<Tab title="NodeJS SDK">
194-
<Info>The SDK supports the `POST` method currently.</Info>
195-
1. Instantiate your Portkey client
196-
2. Use the `.post(url, requestParams)` method to make requests:
274+
The SDK fully supports all HTTP methods: `POST`, `GET`, `PUT`, and `DELETE`.
197275

198-
```javascript
276+
<CodeGroup>
277+
```javascript POST
199278
import Portkey from 'portkey-ai';
200279

201280
const portkey = new Portkey({
@@ -212,6 +291,44 @@ const response = await portkey.post('/rerank', {
212291
]
213292
});
214293
```
294+
295+
```javascript GET
296+
import Portkey from 'portkey-ai';
297+
298+
const portkey = new Portkey({
299+
apiKey: "PORTKEY_API_KEY",
300+
virtualKey: "PROVIDER_VIRTUAL_KEY"
301+
});
302+
303+
const response = await portkey.get('/collections');
304+
```
305+
306+
```javascript PUT
307+
import Portkey from 'portkey-ai';
308+
309+
const portkey = new Portkey({
310+
apiKey: "PORTKEY_API_KEY",
311+
virtualKey: "PROVIDER_VIRTUAL_KEY"
312+
});
313+
314+
const response = await portkey.put('/collections/my-collection', {
315+
metadata: {
316+
description: "Updated collection description"
317+
}
318+
});
319+
```
320+
321+
```javascript DELETE
322+
import Portkey from 'portkey-ai';
323+
324+
const portkey = new Portkey({
325+
apiKey: "PORTKEY_API_KEY",
326+
virtualKey: "PROVIDER_VIRTUAL_KEY"
327+
});
328+
329+
const response = await portkey.delete('/collections/my-collection');
330+
```
331+
</CodeGroup>
215332
</Tab>
216333
</Tabs>
217334

@@ -247,8 +364,8 @@ response = portkey.post(
247364
# Caveats & Considerations
248365

249366
- Response objects are returned exactly as received from the provider, without Portkey transformations
250-
- REST API supports all HTTP methods
251-
- SDK currently supports `POST` only (more methods coming soon)
367+
- REST API supports all HTTP methods: `POST`, `GET`, `PUT`, and `DELETE`
368+
- SDK supports all HTTP methods: `POST`, `GET`, `PUT`, and `DELETE`
252369
- There are no limitations on which provider endpoints can be proxied
253370
- All requests are logged and monitored through your Portkey dashboard
254371

integrations/agents/crewai.mdx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -345,15 +345,15 @@ When deploying agents in production, security is crucial. Portkey provides enter
345345
<Card title="Budget Controls" icon="money-bill">
346346
Set and monitor spending limits per Virtual Key. Get alerts before costs exceed thresholds.
347347
</Card>
348-
348+
349349
<Card title="Access Management" icon="lock">
350350
Control who can access what. Assign roles and permissions for your team members.
351351
</Card>
352-
352+
353353
<Card title="Audit Logging" icon="list-check">
354354
Track all changes and access. Know who modified agent settings and when.
355355
</Card>
356-
356+
357357
<Card title="Data Privacy" icon="shield-check">
358358
Configure data retention and processing policies to meet your compliance needs.
359359
</Card>
@@ -399,13 +399,3 @@ For more information on using these features and setting up your Config, please
399399
<Frame>
400400
<img src="/images/libraries/libraries-3.avif"/>
401401
</Frame>
402-
403-
404-
405-
406-
407-
408-
409-
410-
411-

0 commit comments

Comments
 (0)