Calls
Accept call
client.Realtime.Calls.Accept(ctx, callID, body) error
post /realtime/calls/{call_id}/accept
Accept call
Parameters
-
callID string -
body CallAcceptParams-
RealtimeSessionCreateRequest param.Field[RealtimeSessionCreateRequest]Realtime session object configuration.
-
Example
package main
import (
"context"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
"github.com/openai/openai-go/realtime"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("My API Key"),
)
err := client.Realtime.Calls.Accept(
context.TODO(),
"call_id",
realtime.CallAcceptParams{
RealtimeSessionCreateRequest: realtime.RealtimeSessionCreateRequestParam{
},
},
)
if err != nil {
panic(err.Error())
}
}
Hang up call
client.Realtime.Calls.Hangup(ctx, callID) error
post /realtime/calls/{call_id}/hangup
Hang up call
Parameters
callID string
Example
package main
import (
"context"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("My API Key"),
)
err := client.Realtime.Calls.Hangup(context.TODO(), "call_id")
if err != nil {
panic(err.Error())
}
}
Refer call
client.Realtime.Calls.Refer(ctx, callID, body) error
post /realtime/calls/{call_id}/refer
Refer call
Parameters
-
callID string -
body CallReferParams-
TargetUri param.Field[string]URI that should appear in the SIP Refer-To header. Supports values like
tel:+14155550123orsip:agent@example.com.
-
Example
package main
import (
"context"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
"github.com/openai/openai-go/realtime"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("My API Key"),
)
err := client.Realtime.Calls.Refer(
context.TODO(),
"call_id",
realtime.CallReferParams{
TargetUri: "tel:+14155550123",
},
)
if err != nil {
panic(err.Error())
}
}
Reject call
client.Realtime.Calls.Reject(ctx, callID, body) error
post /realtime/calls/{call_id}/reject
Reject call
Parameters
-
callID string -
body CallRejectParams-
StatusCode param.Field[int64]SIP response code to send back to the caller. Defaults to
603(Decline) when omitted.
-
Example
package main
import (
"context"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
"github.com/openai/openai-go/realtime"
)
func main() {
client := openai.NewClient(
option.WithAPIKey("My API Key"),
)
err := client.Realtime.Calls.Reject(
context.TODO(),
"call_id",
realtime.CallRejectParams{
},
)
if err != nil {
panic(err.Error())
}
}