Skip to content

Commit

Permalink
⚙️ chore(README): update Azure instructions and examples
Browse files Browse the repository at this point in the history
  • Loading branch information
huangdijia committed May 5, 2023
1 parent 97e3d85 commit 3efdbf5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"words": [
"businessworker",
"davinci",
"gatewayworker",
"laravel",
"openai",
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,28 @@ $result = di(OpenAI\Client::class)->completions()->create([
echo $result['choices'][0]['text']; // an open-source, widely-used, server-side scripting language.
```

## Azure

In order to use the Azure OpenAI Service, it is necessary to construct the client manually using the factory.

```php
$client = OpenAI::factory()
->withBaseUri('{your-resource-name}.openai.azure.com/openai/deployments/{deployment-id}')
->withHttpHeader('api-key', '{your-api-key}')
->withQueryParam('api-version', '{version}')
->make();
```

To use Azure, you must deploy a model, identified by the {deployment-id}, which is already incorporated into the API calls. As a result, you do not have to provide the model during the calls since it is included in the BaseUri.

Therefore, a basic sample completion call would be:

```php
$result = $client->completions()->create([
'prompt' => 'PHP is'
]);
```

## Usage

For usage examples, take a look at the [openai-php/client](https://github.com/openai-php/client) repository.
Expand Down

0 comments on commit 3efdbf5

Please sign in to comment.