mirror of
https://github.com/hanzoai/go-openai-realtime.git
synced 2026-09-30 21:54:42 +00:00
Modules declare go 1.27.1 and the build images follow. go fix applied the modernizers, and the examples print streamed deltas with Print instead of using them as format strings; omitzero is not applied, since it changes what the JSON says. Co-Authored-By: Claude Opus 5 <[email protected]>
31 lines
767 B
Go
31 lines
767 B
Go
package openairt_test
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"testing"
|
|
|
|
openairt "github.com/hanzoai/go-openai-realtime"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestCreateSession(t *testing.T) {
|
|
key := os.Getenv("OPENAI_API_KEY")
|
|
if key == "" {
|
|
t.Skip("OPENAI_API_KEY is not set")
|
|
}
|
|
client := openairt.NewClient(key)
|
|
session, err := client.CreateSession(context.Background(), &openairt.CreateSessionRequest{
|
|
Model: openairt.GPT4oRealtimePreview20241217,
|
|
Modalities: []openairt.Modality{
|
|
openairt.ModalityAudio,
|
|
openairt.ModalityText,
|
|
},
|
|
Instructions: "You are a friendly assistant.",
|
|
})
|
|
require.NoError(t, err)
|
|
require.NotEmpty(t, session.ClientSecret.Value)
|
|
require.NotZero(t, session.ClientSecret.ExpiresAt)
|
|
t.Logf("session: %+v", session)
|
|
}
|