|
44 | 44 | description: Turn audio into text or text into audio. |
45 | 45 | - name: Chat |
46 | 46 | description: Given a list of messages comprising a conversation, the model will return a response. |
| 47 | + - name: Realtime |
| 48 | + description: WebSocket proxy for provider Realtime APIs |
47 | 49 | - name: Collections |
48 | 50 | description: Create, List, Retrieve, Update, and Delete collections of prompts. |
49 | 51 | - name: Labels |
@@ -301,6 +303,128 @@ paths: |
301 | 303 |
|
302 | 304 | main(); |
303 | 305 |
|
| 306 | + /realtime: |
| 307 | + servers: *DataPlaneServers |
| 308 | + get: |
| 309 | + operationId: connectRealtime |
| 310 | + tags: |
| 311 | + - Realtime |
| 312 | + summary: Realtime |
| 313 | + description: "Connect to the Realtime API endpoint." |
| 314 | + parameters: |
| 315 | + - $ref: "#/components/parameters/PortkeyTraceId" |
| 316 | + - $ref: "#/components/parameters/PortkeySpanId" |
| 317 | + - $ref: "#/components/parameters/PortkeyParentSpanId" |
| 318 | + - $ref: "#/components/parameters/PortkeySpanName" |
| 319 | + - $ref: "#/components/parameters/PortkeyMetadata" |
| 320 | + - $ref: "#/components/parameters/PortkeyCacheNamespace" |
| 321 | + - $ref: "#/components/parameters/PortkeyCacheForceRefresh" |
| 322 | + - name: model |
| 323 | + in: query |
| 324 | + required: false |
| 325 | + schema: |
| 326 | + type: string |
| 327 | + description: Often required for OpenAI-style realtime; other query params pass through unchanged. |
| 328 | + responses: |
| 329 | + "101": |
| 330 | + description: WebSocket upgrade. |
| 331 | + default: |
| 332 | + description: Error |
| 333 | + security: |
| 334 | + - Portkey-Key: [] |
| 335 | + Virtual-Key: [] |
| 336 | + - Portkey-Key: [] |
| 337 | + Provider-Auth: [] |
| 338 | + Provider-Name: [] |
| 339 | + - Portkey-Key: [] |
| 340 | + Config: [] |
| 341 | + - Portkey-Key: [] |
| 342 | + Provider-Auth: [] |
| 343 | + Provider-Name: [] |
| 344 | + Custom-Host: [] |
| 345 | + x-code-samples: |
| 346 | + - lang: cURL |
| 347 | + label: Default |
| 348 | + source: | |
| 349 | + curl -sS -D - -o /dev/null \ |
| 350 | + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ |
| 351 | + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ |
| 352 | + "https://api.portkey.ai/v1/realtime?model=gpt-4o-realtime-preview" |
| 353 | + - lang: cURL |
| 354 | + label: Self-Hosted |
| 355 | + source: | |
| 356 | + curl -sS -D - -o /dev/null \ |
| 357 | + -H "x-portkey-api-key: $PORTKEY_API_KEY" \ |
| 358 | + -H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \ |
| 359 | + "SELF_HOSTED_GATEWAY_URL/realtime?model=gpt-4o-realtime-preview" |
| 360 | + - lang: javascript |
| 361 | + label: Default |
| 362 | + source: | |
| 363 | + import WebSocket from 'ws'; |
| 364 | + |
| 365 | + const ws = new WebSocket( |
| 366 | + 'wss://api.portkey.ai/v1/realtime?model=gpt-4o-realtime-preview', |
| 367 | + { |
| 368 | + headers: { |
| 369 | + 'x-portkey-api-key': process.env.PORTKEY_API_KEY, |
| 370 | + 'x-portkey-virtual-key': process.env.PORTKEY_PROVIDER_VIRTUAL_KEY, |
| 371 | + }, |
| 372 | + } |
| 373 | + ); |
| 374 | + - lang: javascript |
| 375 | + label: Self-Hosted |
| 376 | + source: | |
| 377 | + import WebSocket from 'ws'; |
| 378 | + |
| 379 | + const u = new URL(process.env.SELF_HOSTED_GATEWAY_URL); |
| 380 | + u.protocol = u.protocol === 'https:' ? 'wss:' : 'ws:'; |
| 381 | + u.pathname = `${u.pathname.replace(/\/$/, '')}/realtime`; |
| 382 | + u.searchParams.set('model', 'gpt-4o-realtime-preview'); |
| 383 | + new WebSocket(u.toString(), { |
| 384 | + headers: { |
| 385 | + 'x-portkey-api-key': process.env.PORTKEY_API_KEY, |
| 386 | + 'x-portkey-virtual-key': process.env.PORTKEY_PROVIDER_VIRTUAL_KEY, |
| 387 | + }, |
| 388 | + }); |
| 389 | + - lang: python |
| 390 | + label: Default |
| 391 | + source: | |
| 392 | + import os |
| 393 | + import asyncio |
| 394 | + import websockets |
| 395 | + |
| 396 | + async def main(): |
| 397 | + uri = "wss://api.portkey.ai/v1/realtime?model=gpt-4o-realtime-preview" |
| 398 | + headers = { |
| 399 | + "x-portkey-api-key": os.environ["PORTKEY_API_KEY"], |
| 400 | + "x-portkey-virtual-key": os.environ["PORTKEY_PROVIDER_VIRTUAL_KEY"], |
| 401 | + } |
| 402 | + async with websockets.connect(uri, extra_headers=headers): |
| 403 | + pass |
| 404 | + |
| 405 | + asyncio.run(main()) |
| 406 | + - lang: python |
| 407 | + label: Self-Hosted |
| 408 | + source: | |
| 409 | + import os |
| 410 | + import asyncio |
| 411 | + from urllib.parse import urlparse, urlunparse |
| 412 | + import websockets |
| 413 | + |
| 414 | + async def main(): |
| 415 | + p = urlparse(os.environ["SELF_HOSTED_GATEWAY_URL"]) |
| 416 | + scheme = "wss" if p.scheme == "https" else "ws" |
| 417 | + path = p.path.rstrip("/") + "/realtime" |
| 418 | + uri = urlunparse((scheme, p.netloc, path, "", "model=gpt-4o-realtime-preview", "")) |
| 419 | + headers = { |
| 420 | + "x-portkey-api-key": os.environ["PORTKEY_API_KEY"], |
| 421 | + "x-portkey-virtual-key": os.environ["PORTKEY_PROVIDER_VIRTUAL_KEY"], |
| 422 | + } |
| 423 | + async with websockets.connect(uri, extra_headers=headers): |
| 424 | + pass |
| 425 | + |
| 426 | + asyncio.run(main()) |
| 427 | + |
304 | 428 | /completions: |
305 | 429 | servers: *DataPlaneServers |
306 | 430 | post: |
@@ -36468,6 +36592,17 @@ x-code-samples: |
36468 | 36592 | - type: object |
36469 | 36593 | key: CreateChatCompletionStreamResponse |
36470 | 36594 | path: streaming |
| 36595 | + - id: realtime |
| 36596 | + title: Realtime |
| 36597 | + description: | |
| 36598 | + WebSocket proxy for provider Realtime APIs (`GET` upgrade). Use `wss://` with the same `/v1` data-plane base as other gateway routes. |
| 36599 | + |
| 36600 | + Related guide: [OpenAI Realtime API](https://platform.openai.com/docs/guides/realtime) |
| 36601 | + navigationGroup: endpoints |
| 36602 | + sections: |
| 36603 | + - type: endpoint |
| 36604 | + key: connectRealtime |
| 36605 | + path: connect |
36471 | 36606 | - id: embeddings |
36472 | 36607 | title: Embeddings |
36473 | 36608 | description: | |
|
0 commit comments