go/resources/realtime/subresources/calls/index.md +0 −186 deleted
File Deleted View Diff
1# Calls
2
3## Accept call
4
5`client.Realtime.Calls.Accept(ctx, callID, body) error`
6
7**post** `/realtime/calls/{call_id}/accept`
8
9Accept an incoming SIP call and configure the realtime session that will
10handle it.
11
12### Parameters
13
14- `callID string`
15
16- `body CallAcceptParams`
17
18 - `RealtimeSessionCreateRequest param.Field[RealtimeSessionCreateRequest]`
19
20 Realtime session object configuration.
21
22### Example
23
24```go
25package main
26
27import (
28 "context"
29
30 "github.com/openai/openai-go"
31 "github.com/openai/openai-go/option"
32 "github.com/openai/openai-go/realtime"
33)
34
35func main() {
36 client := openai.NewClient(
37 option.WithAPIKey("My API Key"),
38 )
39 err := client.Realtime.Calls.Accept(
40 context.TODO(),
41 "call_id",
42 realtime.CallAcceptParams{
43 RealtimeSessionCreateRequest: realtime.RealtimeSessionCreateRequestParam{
44
45 },
46 },
47 )
48 if err != nil {
49 panic(err.Error())
50 }
51}
52```
53
54## Hang up call
55
56`client.Realtime.Calls.Hangup(ctx, callID) error`
57
58**post** `/realtime/calls/{call_id}/hangup`
59
60End an active Realtime API call, whether it was initiated over SIP or
61WebRTC.
62
63### Parameters
64
65- `callID string`
66
67### Example
68
69```go
70package main
71
72import (
73 "context"
74
75 "github.com/openai/openai-go"
76 "github.com/openai/openai-go/option"
77)
78
79func main() {
80 client := openai.NewClient(
81 option.WithAPIKey("My API Key"),
82 )
83 err := client.Realtime.Calls.Hangup(context.TODO(), "call_id")
84 if err != nil {
85 panic(err.Error())
86 }
87}
88```
89
90## Refer call
91
92`client.Realtime.Calls.Refer(ctx, callID, body) error`
93
94**post** `/realtime/calls/{call_id}/refer`
95
96Transfer an active SIP call to a new destination using the SIP REFER verb.
97
98### Parameters
99
100- `callID string`
101
102- `body CallReferParams`
103
104 - `TargetUri param.Field[string]`
105
106 URI that should appear in the SIP Refer-To header. Supports values like
107 `tel:+14155550123` or `sip:agent@example.com`.
108
109### Example
110
111```go
112package main
113
114import (
115 "context"
116
117 "github.com/openai/openai-go"
118 "github.com/openai/openai-go/option"
119 "github.com/openai/openai-go/realtime"
120)
121
122func main() {
123 client := openai.NewClient(
124 option.WithAPIKey("My API Key"),
125 )
126 err := client.Realtime.Calls.Refer(
127 context.TODO(),
128 "call_id",
129 realtime.CallReferParams{
130 TargetUri: "tel:+14155550123",
131 },
132 )
133 if err != nil {
134 panic(err.Error())
135 }
136}
137```
138
139## Reject call
140
141`client.Realtime.Calls.Reject(ctx, callID, body) error`
142
143**post** `/realtime/calls/{call_id}/reject`
144
145Decline an incoming SIP call by returning a SIP status code to the caller.
146
147### Parameters
148
149- `callID string`
150
151- `body CallRejectParams`
152
153 - `StatusCode param.Field[int64]`
154
155 SIP response code to send back to the caller. Defaults to `603` (Decline)
156 when omitted.
157
158### Example
159
160```go
161package main
162
163import (
164 "context"
165
166 "github.com/openai/openai-go"
167 "github.com/openai/openai-go/option"
168 "github.com/openai/openai-go/realtime"
169)
170
171func main() {
172 client := openai.NewClient(
173 option.WithAPIKey("My API Key"),
174 )
175 err := client.Realtime.Calls.Reject(
176 context.TODO(),
177 "call_id",
178 realtime.CallRejectParams{
179
180 },
181 )
182 if err != nil {
183 panic(err.Error())
184 }
185}
186```