Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.17k stars 4.53k forks source link

Invalid model. The model argument should be left blank error #44666

Open PShipstone opened 2 weeks ago

PShipstone commented 2 weeks ago

Library name and version

Azure.AI.OpenAI 2.0.0-beta2

Query/Question

Using C#, I haven't found a great example of how to generate an image using the image client. I'm trying to generate an image using the following code

var client = new OpenAIClient(_settings.OpenApiKey);
var imageClient = client.GetImageClient(_settings.OpenApiModel);

var options = new ImageGenerationOptions
{
    ResponseFormat = GeneratedImageFormat.Uri,
    Quality = GeneratedImageQuality.High,
    Style = GeneratedImageStyle.Natural, 
    Size = GeneratedImageSize.W1024xH1024
};

var image = await imageClient.GenerateImageAsync(prompt, options);

But I'm getting an "Invalid model. The model argument should be left blank error". But GetImageClient expects a model to be specified. I've specified the "gpt-4o" model. I can use the chat client just fine.

How do I correctly generate an image using the image client?

Environment

Microsoft Visual Studio Community 2022 Version 17.10.2 VisualStudio.17.Release/17.10.2+35004.147 Microsoft .NET Framework Version 4.8.09032 Installed Version: Community

.NET SDK: Version: 8.0.300 Commit: 326f6e68b2 Workload version: 8.0.300-manifests.ca8b4b2d MSBuild version: 17.10.4+10fbfbf2e

Runtime Environment: OS Name: Windows OS Version: 10.0.22631 OS Platform: Windows RID: win-x64 Base Path: C:\Program Files\dotnet\sdk\8.0.300\

Host: Version: 8.0.6 Architecture: x64 Commit: 3b8b000a0e

.NET SDKs installed: 8.0.106 [C:\Program Files\dotnet\sdk] 8.0.300 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.31 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.19 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 8.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 8.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found: x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables: Not set

global.json file: Not found

github-actions[bot] commented 2 weeks ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jpalvarezl @ralph-msft @trrwilson.

PShipstone commented 1 week ago

Please ignore this, the error message threw me, taking a second look, I was using the wrong model, should have been using dall-e-3 and not gpt-4o, as always a simple mistake.