Microsoft Agent Framework Integration for Claude

1.0.0b260409 · active · verified Thu Apr 16

The `agent-framework-claude` library provides an integration for using Anthropic's Claude models within Microsoft's Agent Framework. Currently in beta version `1.0.0b260409`, it is part of an actively developed monorepo (`microsoft/agentframework`) with frequent pre-releases, indicating potential for rapid changes and feature updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart initializes a `ClaudeAgent` and demonstrates a simple asynchronous interaction. Ensure your `ANTHROPIC_API_KEY` is set as an environment variable or passed directly. The `model` parameter is recommended for explicit control.

import os
import asyncio
from agentframework.integrations.claude import ClaudeAgent

async def main():
    # Ensure ANTHROPIC_API_KEY is set in your environment
    anthropic_api_key = os.environ.get('ANTHROPIC_API_KEY', '')
    if not anthropic_api_key:
        print("Warning: ANTHROPIC_API_KEY environment variable not set. Agent may not function.")

    agent = ClaudeAgent(
        name="Claude",
        description="An agent that uses Claude for general purpose reasoning.",
        anthropic_api_key=anthropic_api_key,
        model="claude-3-opus-20240229" # Specify your desired Claude model
    )

    # Example interaction
    response = await agent.invoke("What is the capital of France?")
    print(f"Claude's response: {response}")

if __name__ == '__main__':
    asyncio.run(main())

view raw JSON →