Skip to content

Commit b0abe08

Browse files
Merge pull request #639 from eliasto/add-ovhcloud-ai-endpoints-documentation
2 parents 8016398 + cfba7a6 commit b0abe08

File tree

3 files changed

+288
-0
lines changed

3 files changed

+288
-0
lines changed

api-reference/inference-api/supported-providers.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ mode: "wide"
5555
| Nebius |||||||||||||| |
5656
| NCompass |||||||||||||| |
5757
| NScale |||||||||||||| |
58+
| OVHcloud AI Endpoints |||||||||||||| |
5859
| Recraft AI |||||||||||||| |
5960
| Replicate |||||||||||||| |
6061
| Sambanova |||||||||||||| |

docs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@
367367
"integrations/llms/nebius",
368368
"integrations/llms/oracle",
369369
"integrations/llms/openrouter",
370+
"integrations/llms/ovhcloud",
370371
"integrations/llms/perplexity-ai",
371372
"integrations/llms/predibase",
372373
"integrations/llms/reka-ai",

integrations/llms/ovhcloud.mdx

Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
---
2+
title: "OVHcloud AI Endpoints"
3+
---
4+
5+
Portkey provides a robust and secure gateway to facilitate the integration of various Large Language Models (LLMs) into your applications, including [OVHcloud AI Endpoints](https://www.ovhcloud.com/en/public-cloud/ai-endpoints/).
6+
7+
With Portkey, you can take advantage of features like fast AI gateway access, observability, prompt management, and more, all while ensuring the secure management of your LLM API keys through a [virtual key](/product/ai-gateway/virtual-keys) system.
8+
<Note>
9+
Provider Slug. `ovhcloud`
10+
</Note>
11+
## Portkey SDK Integration with OVHcloud AI Endpoints Models
12+
13+
Portkey provides a consistent API to interact with models from various providers. To integrate AI Endpoints with Portkey:
14+
15+
### 1\. Install the Portkey SDK
16+
17+
Add the Portkey SDK to your application to interact with AI Endpoints's API through Portkey's gateway.
18+
19+
<Tabs>
20+
<Tab title="NodeJS">
21+
```sh
22+
npm install --save portkey-ai
23+
```
24+
</Tab>
25+
<Tab title="Python">
26+
```sh
27+
pip install portkey-ai
28+
```
29+
</Tab>
30+
31+
</Tabs>
32+
33+
34+
35+
36+
### 2\. Initialize Portkey with the Virtual Key
37+
38+
To use AI Endpoints with Portkey, [navigate to OVHcloud control panel](https://ovh.com/manager), in the `Public Cloud` section, then in `AI & Machine Learning` in AI Endpoints > API key. You can then add it to Portkey to create the virtual key.
39+
40+
<Tabs>
41+
<Tab title="NodeJS SDK">
42+
43+
```js
44+
import Portkey from 'portkey-ai'
45+
46+
const portkey = new Portkey({
47+
apiKey: "PORTKEY_API_KEY", // defaults to process.env["PORTKEY_API_KEY"]
48+
provider:"@PROVIDER" // Your AI Endpoints Virtual Key
49+
})
50+
```
51+
</Tab>
52+
<Tab title="Python SDK">
53+
```python
54+
from portkey_ai import Portkey
55+
56+
portkey = Portkey(
57+
api_key="PORTKEY_API_KEY", # Replace with your Portkey API key
58+
provider="@PROVIDER" # Replace with your virtual key for AI Endpoints
59+
)
60+
```
61+
62+
</Tab>
63+
64+
</Tabs>
65+
66+
67+
68+
### **3\. Invoke Chat Completions with** AI Endpoints
69+
70+
Use the Portkey instance to send requests to AI Endpoints. You can also override the virtual key directly in the API call if needed.
71+
72+
<Tabs>
73+
<Tab title="NodeJS SDK">
74+
75+
```js
76+
const chatCompletion = await portkey.chat.completions.create({
77+
messages: [{ role: 'user', content: 'Say this is a test' }],
78+
model: 'mixtral-8x7b-32768',
79+
});
80+
81+
console.log(chatCompletion.choices);
82+
```
83+
</Tab>
84+
<Tab title="Python SDK">
85+
86+
```python
87+
completion = portkey.chat.completions.create(
88+
messages= [{ "role": 'user', "content": 'Say this is a test' }],
89+
model= 'mistral-medium'
90+
)
91+
92+
print(completion)
93+
```
94+
95+
</Tab>
96+
97+
</Tabs>
98+
99+
100+
## Managing OVHcloud AI Endpoints Prompts
101+
102+
You can manage all prompts to AI Endpoints in the [Prompt Library](/product/prompt-library). All the current models of AI Endpoints are supported and you can easily start testing different prompts.
103+
104+
Once you're ready with your prompt, you can use the `portkey.prompts.completions.create` interface to use the prompt in your application.
105+
106+
107+
108+
### AI Endpoints Tool Calling
109+
Tool calling feature lets models trigger external tools based on conversation context. You define available functions, the model chooses when to use them, and your application executes them and returns results.
110+
111+
Portkey supports AI Endpoints Tool Calling and makes it interoperable across multiple providers. With Portkey Prompts, you can templatize various your prompts & tool schemas as well.
112+
113+
<Card title="Supported OVHcloud AI Endpoints Models with Tool Calling" href="https://www.ovhcloud.com/en/public-cloud/ai-endpoints/catalog/">
114+
115+
</Card>
116+
117+
<Tabs>
118+
<Tab title="Node.js">
119+
```javascript Get Weather Tool
120+
let tools = [{
121+
type: "function",
122+
function: {
123+
name: "getWeather",
124+
description: "Get the current weather",
125+
parameters: {
126+
type: "object",
127+
properties: {
128+
location: { type: "string", description: "City and state" },
129+
unit: { type: "string", enum: ["celsius", "fahrenheit"] }
130+
},
131+
required: ["location"]
132+
}
133+
}
134+
}];
135+
136+
let response = await portkey.chat.completions.create({
137+
model: "gpt-oss-120b",
138+
messages: [
139+
{ role: "system", content: "You are a helpful assistant." },
140+
{ role: "user", content: "What's the weather like in Delhi - respond in JSON" }
141+
],
142+
tools,
143+
tool_choice: "auto",
144+
});
145+
146+
console.log(response.choices[0].finish_reason);
147+
```
148+
</Tab>
149+
<Tab title="Python">
150+
```python Get Weather Tool
151+
tools = [{
152+
"type": "function",
153+
"function": {
154+
"name": "getWeather",
155+
"description": "Get the current weather",
156+
"parameters": {
157+
"type": "object",
158+
"properties": {
159+
"location": {"type": "string", "description": "City and state"},
160+
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
161+
},
162+
"required": ["location"]
163+
}
164+
}
165+
}]
166+
167+
response = portkey.chat.completions.create(
168+
model="gpt-oss-120b",
169+
messages=[
170+
{"role": "system", "content": "You are a helpful assistant."},
171+
{"role": "user", "content": "What's the weather like in Delhi - respond in JSON"}
172+
],
173+
tools=tools,
174+
tool_choice="auto"
175+
)
176+
177+
print(response.choices[0].finish_reason)
178+
```
179+
</Tab>
180+
<Tab title="cURL">
181+
```curl Get Weather Tool
182+
curl -X POST "https://api.portkey.ai/v1/chat/completions" \
183+
-H "Content-Type: application/json" \
184+
-H "Authorization: Bearer YOUR_PORTKEY_API_KEY" \
185+
-d '{
186+
"model": "gpt-oss-120b",
187+
"messages": [
188+
{"role": "system", "content": "You are a helpful assistant."},
189+
{"role": "user", "content": "What'\''s the weather like in Delhi - respond in JSON"}
190+
],
191+
"tools": [{
192+
"type": "function",
193+
"function": {
194+
"name": "getWeather",
195+
"description": "Get the current weather",
196+
"parameters": {
197+
"type": "object",
198+
"properties": {
199+
"location": {"type": "string", "description": "City and state"},
200+
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]}
201+
},
202+
"required": ["location"]
203+
}
204+
}
205+
}],
206+
"tool_choice": "auto"
207+
}'
208+
```
209+
</Tab>
210+
<Tab title="Portkey Prompts">
211+
</Tab>
212+
</Tabs>
213+
214+
215+
216+
217+
218+
219+
220+
221+
### AI Endpoints Speech to Text (Whisper)
222+
223+
OpenAI's Audio API converts speech to text using the Whisper model. It offers transcription in the original language and translation to English, supporting multiple file formats and languages with high accuracy.
224+
225+
<CodeGroup>
226+
```python Python
227+
audio_file= open("/path/to/file.mp3", "rb")
228+
229+
# Transcription
230+
transcription = portkey.audio.transcriptions.create(
231+
model="whisper-large-v3",
232+
file=audio_file
233+
)
234+
print(transcription.text)
235+
236+
# Translation
237+
translation = portkey.audio.translations.create(
238+
model="whisper-large-v3",
239+
file=audio_file
240+
)
241+
print(translation.text)
242+
```
243+
244+
```javascript Node.js
245+
import fs from "fs";
246+
247+
// Transcription
248+
async function transcribe() {
249+
const transcription = await portkey.audio.transcriptions.create({
250+
file: fs.createReadStream("/path/to/file.mp3"),
251+
model: "whisper-large-v3",
252+
});
253+
console.log(transcription.text);
254+
}
255+
transcribe();
256+
257+
// Translation
258+
async function translate() {
259+
const translation = await portkey.audio.translations.create({
260+
file: fs.createReadStream("/path/to/file.mp3"),
261+
model: "whisper-large-v3",
262+
});
263+
console.log(translation.text);
264+
}
265+
translate();
266+
```
267+
268+
```curl REST
269+
# Transcription
270+
curl -X POST "https://api.portkey.ai/v1/audio/transcriptions" \
271+
-H "Authorization: Bearer YOUR_PORTKEY_API_KEY" \
272+
-H "Content-Type: multipart/form-data" \
273+
-F "file=@/path/to/file.mp3" \
274+
-F "model=whisper-large-v3"
275+
276+
# Translation
277+
curl -X POST "https://api.portkey.ai/v1/audio/translations" \
278+
-H "Authorization: Bearer YOUR_PORTKEY_API_KEY" \
279+
-H "Content-Type: multipart/form-data" \
280+
-F "file=@/path/to/file.mp3" \
281+
-F "model=whisper-large-v3"
282+
```
283+
</CodeGroup>
284+
285+
286+
---

0 commit comments

Comments
 (0)