Skip to content

Commit

Permalink
Document AzureAI *and* OpenAI realtime APIs [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Nov 3, 2024
1 parent 596b34d commit 60caf4a
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,11 @@ The realtime API allows streaming audio and/or text to and from language models,
use com\openai\realtime\RealtimeApi;
use util\cmd\Console;

$api= new RealtimeApi('wss://example.openai.azure.com/openai/realtime?'.
'?api-version=2024-10-01-preview'.
'&deployment=gpt-4o-realtime-preview'
);
$session= $api->connect(['api-key' => getenv('AZUREAI_API_KEY')]);
$api= new RealtimeApi('wss://api.openai.com/v1/realtime?model=gpt-4o-realtime-preview');
$session= $api->connect([
'Authorization' => 'Bearer '.getenv('OPENAI_API_KEY'),
'OpenAI-Beta' => 'realtime=v1',
];
Console::writeLine($session);

// Send prompt
Expand All @@ -341,6 +341,19 @@ do {
$api->close();
```

For Azure AI, the setup code is slightly different:

```php
use com\openai\realtime\RealtimeApi;
use util\cmd\Console;

$api= new RealtimeApi('wss://example.openai.azure.com/openai/realtime?'.
'?api-version=2024-10-01-preview'.
'&deployment=gpt-4o-realtime-preview'
);
$session= $api->connect(['api-key' => getenv('AZUREAI_API_KEY')]);
```

See also
--------
* https://github.com/openai/tiktoken/
Expand Down

0 comments on commit 60caf4a

Please sign in to comment.