Comments (7)
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jpalvarezl @trrwilson.
from azure-sdk-for-net.
Hello, @godefroi! The client configuration pattern is a little different from before; you need to create your ChatClient
instance via the method on the AzureOpenAIClient
you configured, as described in more detail in the readme:
Modifying your shared code:
var azureClient = new AzureOpenAIClient(
_endpointUri,
_apiKey,
new AzureOpenAIClientOptions(AzureOpenAIClientOptions.ServiceVersion.V2024_04_01_Preview));
ChatClient client = azureClient.GetChatClient("my-gpt-35-turbo-deployment");
var completion = client.CompleteChat([new UserChatMessage("What model are you?")]);
Could you please try with the above and report back?
from azure-sdk-for-net.
@trrwilson Shoot, I managed to copy/paste the wrong code. This code:
var client = new AzureOpenAIClient(_endpointUri, _apiKey, new AzureOpenAIClientOptions(AzureOpenAIClientOptions.ServiceVersion.V2024_04_01_Preview));
var chatClient = client.GetChatClient("my-gpt-35-turbo-deployment");
var completion = chatClient.CompleteChat([new UserChatMessage("What model are you?")]);
foreach (var c in completion.Value.Content) {
Console.WriteLine(c.Text);
}
This code fails with the "400 (Missing Authorization header)" error.
from azure-sdk-for-net.
According to the api description shown in the documentation, AzureML provides an API that is compatible with OpenAI endpoints. It does not seem to be exactly the same as Azure OpenAI, e.g. chat/completions, embeddings, the authentication methods etc. paths.
I think the original OpenAI SDK
should be used, not the Azure OpenAI SDK
. As you mentioned at the beginning the OpenAI SDK
works fine.
However, the documentation does mention compatibility with Azure OpenAI. This may require an explanation from Microsoft.
The API is compatible with Azure OpenAI model deployments.
Azure ML Interface API: https://learn.microsoft.com/en-us/azure/machine-learning/reference-model-inference-api?view=azureml-api-2&tabs=rest
Azure OpenAI REST API: https://learn.microsoft.com/en-us/azure/ai-services/openai/reference
from azure-sdk-for-net.
The issue isn't with the API, it's with how the SDK configures the ChatClient. The Azure OpenAI SDK is based on the OpenAI SDK, and the OpenAI SDK works. The Azure OpenAI SDK (contained in this project) fails to configure the underlying classes correctly. Thus, this is an issue with the Azure OpenAI SDK.
from azure-sdk-for-net.
Does the non-Azure client (i.e. substituting OpenAIClient
for AzureOpenAIClient
) properly connect to the endpoint?
OpenAI and Azure OpenAI authenticate differently -- that's one of the primary drivers for the client being needed -- and it sounds like AzureML may be matching OpenAI rather than Azure OpenAI. Specifically, Azure OpenAI uses an api-key
header for keys, while OpenAI (and, from that error message, AzureML) use Authorization
.
Alternatively -- and although I believe this will work, I haven't confirmed it -- you could use a DelegatedTokenCredential
to "spoof" the expected Authorization: bearer
header, e.g.:
TokenCredential authorizationCredential = DelegatedTokenCredential.Create(
(context, cancellationToken) =>
{
return new AccessToken(Environment.GetEnvironmentVariable("AZUREML_API_KEY"), DateTime.MaxValue);
});
AzureOpenAIClient azureClient = new(
new Uri(Environment.GetEnvironmentVariable("AZUREML_ENDPOINT")),
authorizationCredential,
new AzureOpenAIClientOptions(
AzureOpenAIClientOptions.ServiceVersion.V2024_04_01_Preview));
from azure-sdk-for-net.
Does the non-Azure client (i.e. substituting OpenAIClient for AzureOpenAIClient) properly connect to the endpoint?
Yes. OpenAIClient
works as expected. Your alternate workaround with DelegatedTokenCredential
, however, does not. It results in a 405 (Method Not Allowed)
response.
from azure-sdk-for-net.
Related Issues (20)
- Exception Information Missing HOT 1
- [QUERY] Is there a way to specify the api version in SAS Token? HOT 1
- [FEATURE REQ]Add List and Put functions in EncryptionScopeResource HOT 1
- [QUERY] How to mock SubscriptionCollection resources. HOT 2
- [QUERY] Why is ShareAccessTier Premium missing from the .NET SDK HOT 2
- [QUERY] How to add new access policy to key vault without deleting all existing access policies? HOT 2
- [BUG]: Upgrade Azure.Identity Microsoft.Identity.Client to latest version to resolve security vulnerability HOT 2
- [QUERY] Azure.Identity 1.11.4: how to use WebView2 control? HOT 17
- [QUERY] What is happening with EventGridClient class? HOT 3
- How can we Enable/Disable APIs and Operations in Azure API Management Using .NET SDK and or in Portal HOT 1
- [BUG] Azure Service Bus Timeout instead of correct response: MessagingEntityNotFound HOT 8
- [AppConfig] Update Live Tests for Filter By Tags Feature
- [BUG] Azure.Search.Documents performs vector search successfully, but results are "null" HOT 1
- [QUERY] OpenAI Assistants V2 on Azure - Activate File search on assistant + specify file_ids in message's attachments HOT 4
- infinite lease via break? HOT 2
- [FEATURE REQ] Open Telemetry Sample Request HOT 3
- [BUG] API consistency issue, ManagedIdentityCredential() does not read default values from environment variables, like other Credentials. HOT 1
- [BUG] [OpenAI] ClientResultException 400 Bad Request calling `AzureChatClient.CompleteChatAsync` with PineconeChatDataSource HOT 2
- [FEATURE REQ] Support IsStored for any string field in Azure AI Search HOT 2
- [BUG]Failed to download PEM certificate from azure.keyvault with failure "The provided key does not match the public key for this certificate" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-sdk-for-net.