'IChatClient' does not contain a definition for 'UseFunctionInvocation', and its sibling The type or namespace name 'ChatClientBuilder' could not be found, mean the project references Microsoft.Extensions.AI.Abstractions but not Microsoft.Extensions.AI. The builder, AsBuilder() and UseFunctionInvocation() all live in the second package. Add it and build again.

Run dotnet add package Microsoft.Extensions.AI in the project folder. Then call UseFunctionInvocation() on a builder, not on the client itself: new ChatClientBuilder(client).UseFunctionInvocation().Build().

The error

...\AiLab\Program.cs(4,9): error CS0246: The type or namespace name 'ChatClientBuilder' could not be found (are you missing a using directive or an assembly reference?) [...\AiLab\AiLab.csproj]
...\AiLab\Program.cs(9,11): error CS1061: 'IChatClient' does not contain a definition for 'AsBuilder' and no accessible extension method 'AsBuilder' accepting a first argument of type 'IChatClient' could be found (are you missing a using directive or an assembly reference?) [...\AiLab\AiLab.csproj]
...\AiLab\Program.cs(14,11): error CS1061: 'IChatClient' does not contain a definition for 'UseFunctionInvocation' and no accessible extension method 'UseFunctionInvocation' accepting a first argument of type 'IChatClient' could be found (are you missing a using directive or an assembly reference?) [...\AiLab\AiLab.csproj]

The paths are shortened; nothing else was changed. The three lines come from three ways of writing the same call, in a project that referenced only the Abstractions package:

static IChatClient FormA(IChatClient inner) =>
    new ChatClientBuilder(inner)
        .UseFunctionInvocation()
        .Build();

static IChatClient FormB(IChatClient inner) =>
    inner.AsBuilder()
        .UseFunctionInvocation()
        .Build();

static IChatClient FormC(IChatClient inner) =>
    inner.UseFunctionInvocation();

Why it happens

Microsoft.Extensions.AI ships as two packages. The Abstractions package holds IChatClient, which is why the code above found that type. ChatClientBuilder and the extension methods that build a pipeline on it are in Microsoft.Extensions.AI. Which one you end up with depends on the provider package. OllamaSharp 5.5.0 depends on Microsoft.Extensions.AI 10.8.0, so the same builder code compiled with OllamaSharp alone. Microsoft.Extensions.AI.OpenAI 10.11.0 depends only on the Abstractions package and the OpenAI SDK, so a project that talks to Ollama through its OpenAI-compatible endpoint gets IChatClient but no builder, and the common form fails with the CS0246 line above.

After the package was added, forms A and B compiled. Form C still failed, now with a message that names the type the method extends:

...\AiLab\Program.cs(14,5): error CS1929: 'IChatClient' does not contain a definition for 'UseFunctionInvocation' and the best extension method overload 'FunctionInvokingChatClientBuilderExtensions.UseFunctionInvocation(ChatClientBuilder, ILoggerFactory?, Action<FunctionInvokingChatClient>?)' requires a receiver of type 'Microsoft.Extensions.AI.ChatClientBuilder' [...\AiLab\AiLab.csproj]

The fix

dotnet add package Microsoft.Extensions.AI
using System.ClientModel;
using Microsoft.Extensions.AI;
using OpenAI;
using OpenAI.Chat;

// Ollama's OpenAI-compatible endpoint; Ollama ignores the key.
var options = new OpenAIClientOptions { Endpoint = new Uri("http://localhost:11434/v1") };
IChatClient ollama = new ChatClient("qwen2.5:3b", new ApiKeyCredential("unused"), options)
    .AsIChatClient();

IChatClient client = new ChatClientBuilder(ollama)
    .UseFunctionInvocation()
    .Build();

Console.WriteLine(client.GetType().Name);

With <PackageReference Include="Microsoft.Extensions.AI" Version="10.11.0" /> next to the OpenAI adapter, the build succeeded and the program printed FunctionInvokingChatClient, the wrapper that runs your tools when the model asks for them. dotnet add package picked 10.11.0 for both packages, the latest stable release on the day, so the adapter and the builder agree on the Abstractions version.

How it was reproduced

On Windows 11 with .NET SDK 10.0.402, in console projects from dotnet new console: one with only Microsoft.Extensions.AI.Abstractions 10.11.0 for the three forms, one with only Microsoft.Extensions.AI.OpenAI 10.11.0 (OpenAI 2.14.0) for the real-world case, and one with only OllamaSharp 5.5.0 as the control that built. All versions were the latest stable releases on the day. Only builds were run; the program creates the client and sends no request to a model.

Frequently asked

Which NuGet package contains UseFunctionInvocation?
Microsoft.Extensions.AI. In version 10.11.0 it is an extension method on ChatClientBuilder, which lives in the same package. Microsoft.Extensions.AI.Abstractions alone contains neither.
Why does UseFunctionInvocation work with OllamaSharp but not with the OpenAI adapter?
OllamaSharp 5.5.0 depends on Microsoft.Extensions.AI, so the builder arrives transitively. Microsoft.Extensions.AI.OpenAI 10.11.0 depends only on the Abstractions package and the OpenAI SDK, so the project must reference Microsoft.Extensions.AI itself.
Can I call UseFunctionInvocation directly on an IChatClient?
No. It extends ChatClientBuilder. Wrap the client with new ChatClientBuilder(client) or client.AsBuilder(), call UseFunctionInvocation(), then Build(). Calling it on the client gives CS1929 once the package is referenced.

Once tool calling compiles, the next error is often the model itself; see ModelDoesNotSupportToolsException, or the full walkthrough in tool calling with Microsoft.Extensions.AI. More decoded errors are in the Fixes category.