Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
135 changes: 135 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ tags:
description: Turn audio into text or text into audio.
- name: Chat
description: Given a list of messages comprising a conversation, the model will return a response.
- name: Realtime
description: WebSocket proxy for provider Realtime APIs
- name: Collections
description: Create, List, Retrieve, Update, and Delete collections of prompts.
- name: Labels
Expand Down Expand Up @@ -301,6 +303,128 @@ paths:

main();

/realtime:
servers: *DataPlaneServers
get:
operationId: connectRealtime
tags:
- Realtime
summary: Realtime
description: "Connect to the Realtime API endpoint."
parameters:
- $ref: "#/components/parameters/PortkeyTraceId"
- $ref: "#/components/parameters/PortkeySpanId"
- $ref: "#/components/parameters/PortkeyParentSpanId"
- $ref: "#/components/parameters/PortkeySpanName"
- $ref: "#/components/parameters/PortkeyMetadata"
- $ref: "#/components/parameters/PortkeyCacheNamespace"
- $ref: "#/components/parameters/PortkeyCacheForceRefresh"
- name: model
in: query
required: false
schema:
type: string
description: Often required for OpenAI-style realtime; other query params pass through unchanged.
responses:
"101":
description: WebSocket upgrade.
default:
description: Error
security:
- Portkey-Key: []
Virtual-Key: []
- Portkey-Key: []
Provider-Auth: []
Provider-Name: []
- Portkey-Key: []
Config: []
- Portkey-Key: []
Provider-Auth: []
Provider-Name: []
Custom-Host: []
x-code-samples:
- lang: cURL
label: Default
source: |
curl -sS -D - -o /dev/null \
-H "x-portkey-api-key: $PORTKEY_API_KEY" \
-H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \
"https://api.portkey.ai/v1/realtime?model=gpt-4o-realtime-preview"
- lang: cURL
label: Self-Hosted
source: |
curl -sS -D - -o /dev/null \
-H "x-portkey-api-key: $PORTKEY_API_KEY" \
-H "x-portkey-virtual-key: $PORTKEY_PROVIDER_VIRTUAL_KEY" \
"SELF_HOSTED_GATEWAY_URL/realtime?model=gpt-4o-realtime-preview"
- lang: javascript
label: Default
source: |
import WebSocket from 'ws';

const ws = new WebSocket(
'wss://api.portkey.ai/v1/realtime?model=gpt-4o-realtime-preview',
{
headers: {
'x-portkey-api-key': process.env.PORTKEY_API_KEY,
'x-portkey-virtual-key': process.env.PORTKEY_PROVIDER_VIRTUAL_KEY,
},
}
);
- lang: javascript
label: Self-Hosted
source: |
import WebSocket from 'ws';

const u = new URL(process.env.SELF_HOSTED_GATEWAY_URL);
u.protocol = u.protocol === 'https:' ? 'wss:' : 'ws:';
u.pathname = `${u.pathname.replace(/\/$/, '')}/realtime`;
u.searchParams.set('model', 'gpt-4o-realtime-preview');
new WebSocket(u.toString(), {
headers: {
'x-portkey-api-key': process.env.PORTKEY_API_KEY,
'x-portkey-virtual-key': process.env.PORTKEY_PROVIDER_VIRTUAL_KEY,
},
});
- lang: python
label: Default
source: |
import os
import asyncio
import websockets

async def main():
uri = "wss://api.portkey.ai/v1/realtime?model=gpt-4o-realtime-preview"
headers = {
"x-portkey-api-key": os.environ["PORTKEY_API_KEY"],
"x-portkey-virtual-key": os.environ["PORTKEY_PROVIDER_VIRTUAL_KEY"],
}
async with websockets.connect(uri, extra_headers=headers):
pass

asyncio.run(main())
- lang: python
label: Self-Hosted
source: |
import os
import asyncio
from urllib.parse import urlparse, urlunparse
import websockets

async def main():
p = urlparse(os.environ["SELF_HOSTED_GATEWAY_URL"])
scheme = "wss" if p.scheme == "https" else "ws"
path = p.path.rstrip("/") + "/realtime"
uri = urlunparse((scheme, p.netloc, path, "", "model=gpt-4o-realtime-preview", ""))
headers = {
"x-portkey-api-key": os.environ["PORTKEY_API_KEY"],
"x-portkey-virtual-key": os.environ["PORTKEY_PROVIDER_VIRTUAL_KEY"],
}
async with websockets.connect(uri, extra_headers=headers):
pass

asyncio.run(main())

/completions:
servers: *DataPlaneServers
post:
Expand Down Expand Up @@ -36468,6 +36592,17 @@ x-code-samples:
- type: object
key: CreateChatCompletionStreamResponse
path: streaming
- id: realtime
title: Realtime
description: |
WebSocket proxy for provider Realtime APIs (`GET` upgrade). Use `wss://` with the same `/v1` data-plane base as other gateway routes.

Related guide: [OpenAI Realtime API](https://platform.openai.com/docs/guides/realtime)
navigationGroup: endpoints
sections:
- type: endpoint
key: connectRealtime
path: connect
- id: embeddings
title: Embeddings
description: |
Expand Down
Loading