Anthropic integration for Microsoft Agent Framework

1.0.0b260409 · active · verified Wed Apr 15

The `agent-framework-anthropic` library provides seamless integration of Anthropic Claude models with the Microsoft Agent Framework. It enables developers to leverage Claude's advanced reasoning, context handling, and thoughtful responses within their AI agent applications. As part of the broader Microsoft Agent Framework ecosystem, it's under active development, with frequent updates given its current beta status.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize an `AnthropicClient` and create a basic AI agent. It assumes the `ANTHROPIC_API_KEY` environment variable is set for authentication with the Anthropic API. The agent is then used to answer a simple question.

import asyncio
import os
from agent_framework.anthropic import AnthropicClient

async def main():
    # Ensure ANTHROPIC_API_KEY is set in your environment variables.
    # For a quick test, you can uncomment and set it directly, but avoid in production.
    # os.environ['ANTHROPIC_API_KEY'] = 'your_anthropic_api_key_here'

    if not os.environ.get('ANTHROPIC_API_KEY'):
        print("Error: ANTHROPIC_API_KEY environment variable is not set.")
        print("Please set it before running the quickstart.")
        return

    client = AnthropicClient()

    # Create an agent using the Anthropic client
    agent = client.as_agent(
        name="HelpfulAssistant",
        instructions="You are a helpful assistant that answers questions accurately.",
    )

    # Run the agent with a prompt
    response = await agent.run("What is the capital of France?")
    print(f"Assistant: {response}")

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

view raw JSON →