images
Learn how to use images with an agent
$ npx -y skills add managedcode/dotnet-skills --agent claude-codeHow it fires
How this agent gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
Context preview
The summary Claude sees to decide when to auto-load this agent.
Learn how to use images with an agent
Agent definition
images.mdtitle: Using images with an agent
description: Learn how to use images with an agent
zone_pivot_groups: programming-languages
author: westey-m
ms.topic: tutorial
ms.author: westey
ms.date: 09/24/2025
ms.service: agent-framework
Using images with an agent
This tutorial shows you how to use images with an agent, allowing the agent to analyze and respond to image content.
Prerequisites
For prerequisites and installing NuGet packages, see the [Create and run a simple agent](./run-agent.md) step in this tutorial.
::: zone pivot="programming-language-csharp"
Passing images to the agent
You can send images to an agent by creating a `ChatMessage` that includes both text and image content. The agent can then analyze the image and respond accordingly.
First, create an `AIAgent` that is able to analyze images.
AIAgent agent = new AzureOpenAIClient(
new Uri("https://<myresource>.openai.azure.com"),
new AzureCliCredential())
.GetChatClient("gpt-4o")
.AsAIAgent(
name: "VisionAgent",
instructions: "You are a helpful agent that can analyze images");Next, create a `ChatMessage` that contains both a text prompt and an image URL. Use `TextContent` for the text and `UriContent` for the image.
ChatMessage message = new(ChatRole.User, [
new TextContent("What do you see in this image?"),
new UriContent("https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg", "image/jpeg")
]);Run the agent with the message. You can use streaming to receive the response as it is generated.
Console.WriteLine(await agent.RunAsync(message));
This will print the agent's analysis of the image to the console.
::: zone-end ::: zone pivot="programming-language-python"
Passing images to the agent
You can send images to an agent by creating a `ChatMessage` that includes both text and image content. The agent can then analyze the image and respond accordingly.
First, create an agent that is able to analyze images.
import asyncio
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
agent = AzureOpenAIChatClient(credential=AzureCliCredential()).as_agent(
name="VisionAgent",
instructions="You are a helpful agent that can analyze images"
)Next, create a `ChatMessage` that contains both a text prompt and an image URL. Use `TextContent` for the text and `UriContent` for the image.
from agent_framework import ChatMessage, TextContent, UriContent, Role
message = ChatMessage(
role=Role.USER,
contents=[
TextContent(text="What do you see in this image?"),
UriContent(
uri="https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
media_type="image/jpeg"
)
]
)You can also load an image from your local file system using `DataContent`:
from agent_framework import ChatMessage, TextContent, DataContent, Role
# Load image from local file
with open("path/to/your/image.jpg", "rb") as f:
image_bytes = f.read()
message = ChatMessage(
role=Role.USER,
contents=[
TextContent(text="What do you see in this image?"),
DataContent(
data=image_bytes,
media_type="image/jpeg"
)
]
)Run the agent with the message. You can use streaming to receive the response as it is generated.
async def main():
result = await agent.run(message)
print(result.text)
asyncio.run(main())This will print the agent's analysis of the image to the console.
::: zone-end
Next steps
> [!div class="nextstepaction"] > [Having a multi-turn conversation with an agent](./multi-turn-conversation.md)
Read more
title: Using images with an agent description: Learn how to use images with an agent zone_pivot_groups: programming-languages author: westey-m ms.topic: tutorial ms.author: westey ms.date: 09/24/2025 ms.service: agent-framework
Using images with an agent
This tutorial shows you how to use images with an agent, allowing the agent to analyze and respond to image content.
Prerequisites
For prerequisites and installing NuGet packages, see the [Create and run a simple agent](./run-agent.md) step in this tutorial.
::: zone pivot="programming-language-csharp"
Passing images to the agent
You can send images to an agent by creating a `ChatMessage` that includes both text and image content. The agent can then analyze the image and respond accordingly.
First, create an `AIAgent` that is able to analyze images.
AIAgent agent = new AzureOpenAIClient(
new Uri("https://<myresource>.openai.azure.com"),
new AzureCliCredential())
.GetChatClient("gpt-4o")
.AsAIAgent(
name: "VisionAgent",
instructions: "You are a helpful agent that can analyze images");Next, create a `ChatMessage` that contains both a text prompt and an image URL. Use `TextContent` for the text and `UriContent` for the image.
ChatMessage message = new(ChatRole.User, [
new TextContent("What do you see in this image?"),
new UriContent("https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg", "image/jpeg")
]);Run the agent with the message. You can use streaming to receive the response as it is generated.
Console.WriteLine(await agent.RunAsync(message));
This will print the agent's analysis of the image to the console.
::: zone-end ::: zone pivot="programming-language-python"
Passing images to the agent
You can send images to an agent by creating a `ChatMessage` that includes both text and image content. The agent can then analyze the image and respond accordingly.
First, create an agent that is able to analyze images.
import asyncio
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
agent = AzureOpenAIChatClient(credential=AzureCliCredential()).as_agent(
name="VisionAgent",
instructions="You are a helpful agent that can analyze images"
)Next, create a `ChatMessage` that contains both a text prompt and an image URL. Use `TextContent` for the text and `UriContent` for the image.
from agent_framework import ChatMessage, TextContent, UriContent, Role
message = ChatMessage(
role=Role.USER,
contents=[
TextContent(text="What do you see in this image?"),
UriContent(
uri="https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
media_type="image/jpeg"
)
]
)You can also load an image from your local file system using `DataContent`:
from agent_framework import ChatMessage, TextContent, DataContent, Role
# Load image from local file
with open("path/to/your/image.jpg", "rb") as f:
image_bytes = f.read()
message = ChatMessage(
role=Role.USER,
contents=[
TextContent(text="What do you see in this image?"),
DataContent(
data=image_bytes,
media_type="image/jpeg"
)
]
)Run the agent with the message. You can use streaming to receive the response as it is generated.
async def main():
result = await agent.run(message)
print(result.text)
asyncio.run(main())This will print the agent's analysis of the image to the console.
::: zone-end
Next steps
> [!div class="nextstepaction"] > [Having a multi-turn conversation with an agent](./multi-turn-conversation.md)
Stop explaining .NET to your AI. Start building. We've all been there: asking Claude to use Entity Framework, only to get EF6 patterns in a .NET 8 project. Explaining to Copilot that Blazor Server and Blazor WebAssembly aren't the same thing.
Repo: managedcode/dotnet-skills
Other agents on dotnet-skills.
- AGENT
Specialist orchestration agent for .NET Aspire work. Use when the problem is clearly about AppHost design, ServiceDefaults, first-party versus CommunityToolkit/Aspire integrations, dashboard and testing, `DistributedApplicationTestingBuilder`, `WebApplicationFactory`
Open agent - agent-as-function-tool
Legacy tutorial alias retained locally; the live Learn URL now resolves into the broader Function Tools surface
Open agent - agent-as-mcp-tool
Learn how to expose an agent as a tool over the MCP protocol
Open agent - create-and-run-durable-agent
Learn how to create and run a durable AI agent with Azure Functions and the durable task extension for Microsoft Agent Framework
Open agent - enable-observability
Enable OpenTelemetry for an agent so agent interactions are automatically logged
Open agent - function-tools-approvals
Learn how to use function tools with human in the loop approvals
Open agent

