import asyncio
import os
from dotenv import load_dotenv
from claude_agent_sdk import (
AgentDefinition, ClaudeSDKClient, ClaudeAgentOptions, AssistantMessage,
)
load_dotenv()
AWS_REGION = os.environ.get("AWS_REGION", "us-west-2")
# Key configuration for Bedrock
os.environ["CLAUDE_CODE_USE_BEDROCK"] = "1"
os.environ["AWS_REGION"] = AWS_REGION
async def main():
agents = {
"docs_researcher": AgentDefinition(
description="Finds information from official documentation.",
prompt="You research official docs.",
tools=["WebSearch", "WebFetch"],
model="haiku"
),
}
options = ClaudeAgentOptions(
system_prompt="You are a helpful assistant.",
allowed_tools=["Skill", "Task", "Write", "Bash", "WebSearch", "WebFetch"],
model="sonnet",
agents=agents
)
async with ClaudeSDKClient(options=options) as client:
await client.query("Hello!")
async for message in client.receive_response():
if isinstance(message, AssistantMessage):
print(message.content)
asyncio.run(main())
Loading article