Realtime 接口
curl --request GET \
--url https://www.geeknow.top/v1/realtime \
--header 'Authorization: Bearer <token>'import requests
url = "https://www.geeknow.top/v1/realtime"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://www.geeknow.top/v1/realtime', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.geeknow.top/v1/realtime",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://www.geeknow.top/v1/realtime"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://www.geeknow.top/v1/realtime")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.geeknow.top/v1/realtime")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body文本系列
Realtime 接口
使用 OpenAI Realtime 兼容 WebSocket 路由进行实时交互。
GET
https://www.geeknow.top
/
v1
/
realtime
Realtime 接口
curl --request GET \
--url https://www.geeknow.top/v1/realtime \
--header 'Authorization: Bearer <token>'import requests
url = "https://www.geeknow.top/v1/realtime"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://www.geeknow.top/v1/realtime', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.geeknow.top/v1/realtime",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://www.geeknow.top/v1/realtime"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://www.geeknow.top/v1/realtime")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.geeknow.top/v1/realtime")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyRealtime 接口
Realtime 路由使用 WebSocket 连接,适合低延迟语音对话、实时事件流和双向交互场景。该路由会经过 TokenAuth、模型限流和渠道分发。连接地址
wss://www.geeknow.top/v1/realtime
认证
Authorization: Bearer YOUR_API_KEY
连接示例
const ws = new WebSocket("wss://www.geeknow.top/v1/realtime", [], {
headers: {
Authorization: "Bearer YOUR_API_KEY",
},
});
ws.onopen = () => {
ws.send(JSON.stringify({
type: "session.update",
session: {
modalities: ["text"],
instructions: "你是一个实时语音助手。"
}
}));
};
ws.onmessage = (event) => {
console.log(JSON.parse(event.data));
};
常见事件
| event | 说明 |
|---|---|
session.update | 更新会话配置 |
conversation.item.create | 创建对话项 |
response.create | 触发模型响应 |
response.text.delta | 文本增量 |
response.done | 响应完成 |
相关接口
⌘I