Skip to content

Commit f9ea5c2

Browse files
authored
Update llama-index.md
1 parent 31d56f9 commit f9ea5c2

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

articles/ai-studio/how-to/develop/llama-index.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export AZURE_INFERENCE_ENDPOINT="<your-model-endpoint-goes-here>"
6767
export AZURE_INFERENCE_CREDENTIAL="<your-key-goes-here>"
6868
```
6969
70-
Once configured, create a client to connect to the endpoint:
70+
Once configured, create a client to connect to the endpoint. The parameter `model_name` in the constructor is not required for endpoints serving a single model, like serverless endpoints.
7171
7272
```python
7373
import os
@@ -80,7 +80,7 @@ llm = AzureAICompletionsModel(
8080
```
8181
8282
> [!TIP]
83-
> The parameter `model_name` in the constructor is not required for endpoints serving a single model, like serverless endpoints).
83+
> If your model is an OpenAI model deployed to Azure OpenAI service or AI services resource, configure the client as indicated at [Azure OpenAI models](#azure-openai-models).
8484
8585
Alternatively, if your endpoint support Microsoft Entra ID, you can use the following code to create the client:
8686
@@ -112,6 +112,23 @@ llm = AzureAICompletionsModel(
112112
)
113113
```
114114

115+
### Azure OpenAI models
116+
117+
If you are using Azure OpenAI models with key-based authentication, you need to pass the authentication key in the header `api-key`, which is the one expected in the Azure OpenAI service and in Azure AI Services. This configuration is not required if you are using Microsoft Entra ID (formerly known as Azure AD). The following example shows how to configure the client:
118+
119+
```python
120+
import os
121+
from llama_index.llms.azure_inference import AzureAICompletionsModel
122+
123+
llm = AzureAICompletionsModel(
124+
endpoint=os.environ["AZURE_INFERENCE_ENDPOINT"],
125+
credential="",
126+
client_kwargs={"headers" : { "api-key": os.environ["AZURE_INFERENCE_CREDENTIAL"] } }
127+
)
128+
```
129+
130+
Notice that `credentials` is still being passed with an empty value since it's a required parameter.
131+
115132
### Inference parameters
116133
117134
You can configure how inference in performed for all the operations that are using this client by setting extra parameters. This helps avoid indicating them on each call you make to the model.

0 commit comments

Comments
 (0)