Image input
A ready-to-run example is available here.
Sending images
Pass images along with text in the message content:
from faheemcode.sdk import ImageContent
IMAGE_URL = "https://github.com/SMART-National-Solution/faheem-code-app/raw/main/docs/static/img/logo.png"
conversation.send_message(
Message(
role="user",
content=[
TextContent(
text=(
"Study this image and describe the key elements you see. "
"Summarize them in a short paragraph and suggest a catchy caption."
)
),
ImageContent(image_urls=[IMAGE_URL]),
],
)
)
Works with multimodal LLMs like GPT-4 Vision and Claude with vision capabilities.
Ready-to-run example
You can send images to multimodal LLMs for vision-based tasks like screenshot analysis, image processing, and visual QA:
"""Faheem Code Agent SDK — Image Input Example.
This script mirrors the basic setup from ``examples/01_hello_world.py`` but adds
vision support by sending an image to the agent alongside text instructions.
"""
import os
from pydantic import SecretStr
from faheemcode.sdk import (
LLM,
Agent,
Conversation,
Event,
ImageContent,
LLMConvertibleEvent,
Message,
TextContent,
get_logger,
)
from faheemcode.sdk.tool.spec import Tool
from faheemcode.tools.file_editor import FileEditorTool
from faheemcode.tools.task_tracker import TaskTrackerTool
from faheemcode.tools.terminal import TerminalTool
logger = get_logger(__name__)
# Configure LLM (vision-capable model)
api_key = os.getenv("LLM_API_KEY")
assert api_key is not None, "LLM_API_KEY environment variable is not set."
model = os.getenv("LLM_MODEL", "anthropic/claude-sonnet-4-5-20250929")
base_url = os.getenv("LLM_BASE_URL")
llm = LLM(
usage_id="vision-llm",
model=model,
base_url=base_url,
api_key=SecretStr(api_key),
)
assert llm.vision_is_active(), "The selected LLM model does not support vision input."
cwd = os.getcwd()
agent = Agent(
llm=llm,
tools=[
Tool(
name=TerminalTool.name,
),
Tool(name=FileEditorTool.name),
Tool(name=TaskTrackerTool.name),
],
)
llm_messages = [] # collect raw LLM messages for inspection
def conversation_callback(event: Event) -> None:
if isinstance(event, LLMConvertibleEvent):
llm_messages.append(event.to_llm_message())
conversation = Conversation(
agent=agent, callbacks=[conversation_callback], workspace=cwd
)
IMAGE_URL = "https://github.com/SMART-National-Solution/faheem-code-docs/raw/main/faheem-code/static/img/logo.png"
conversation.send_message(
Message(
role="user",
content=[
TextContent(
text=(
"Study this image and describe the key elements you see. "
"Summarize them in a short paragraph and suggest a catchy caption."
)
),
ImageContent(image_urls=[IMAGE_URL]),
],
)
)
conversation.run()
conversation.send_message(
"Great! Please save your description and caption into image_report.md."
)
conversation.run()
print("=" * 100)
print("Conversation finished. Got the following LLM messages:")
for i, message in enumerate(llm_messages):
print(f"Message {i}: {str(message)[:200]}")
# Report cost
cost = llm.metrics.accumulated_cost
print(f"EXAMPLE_COST: {cost}")
You can run the example code as-is.
Bring your own provider key
export LLM_API_KEY="your-api-key"
export LLM_MODEL="anthropic/claude-sonnet-4-5-20250929" # or openai/gpt-4o, etc.
cd software-agent-sdk
uv run python examples/01_standalone_sdk/17_image_input.py
Faheem Code Cloud key
# https://app.faheemcode.ai/settings/api-keys
export LLM_API_KEY="example-user-api-key"
export LLM_MODEL="faheemcode/claude-sonnet-4-5-20250929"
cd software-agent-sdk
uv run python examples/01_standalone_sdk/17_image_input.py
Next steps
- Hello World - Learn basic conversation patterns
- Async Operations - Process multiple images concurrently