{"id":14410,"library":"agent-framework-chatkit","title":"OpenAI ChatKit Integration for Microsoft Agent Framework","description":"The `agent-framework-chatkit` library provides an integration with OpenAI's ChatKit (beta) for the Microsoft Agent Framework, enabling developers to leverage ChatKit's agent capabilities within their Agent Framework applications. It is currently in active beta development (version 1.0.0b260409) with frequent updates and potential breaking changes.","status":"active","version":"1.0.0b260409","language":"en","source_language":"en","source_url":"https://github.com/microsoft/AgentFramework/tree/main/src/python/AgentFramework.ChatKit","tags":["AI","agent","OpenAI","ChatKit","Microsoft Agent Framework","beta"],"install":[{"cmd":"pip install agent-framework-chatkit","lang":"bash","label":"Install latest beta"}],"dependencies":[{"reason":"This package integrates with the Microsoft Agent Framework; it is a core prerequisite for its intended use.","package":"agent-framework","optional":false},{"reason":"The library internally uses the OpenAI API for language models, requiring the `openai` package and an API key.","package":"openai","optional":false}],"imports":[{"note":"Despite the PyPI package name being `agent-framework-chatkit`, the top-level import path for components is simply `chatkit`.","wrong":"from agent_framework_chatkit import ChatKitClient","symbol":"ChatKitClient","correct":"from chatkit import ChatKitClient"},{"note":"Similar to `ChatKitClient`, components within submodules also use `chatkit` as the root import path.","wrong":"from agent_framework_chatkit.agents import BasicChatKitAgent","symbol":"BasicChatKitAgent","correct":"from chatkit.agents import BasicChatKitAgent"}],"quickstart":{"code":"import os\nimport asyncio\nfrom chatkit import ChatKitClient\nfrom chatkit.agents import BasicChatKitAgent\nfrom chatkit.messages import TextMessage\n\nasync def main():\n    # Ensure CHATKIT_API_KEY and OPENAI_API_KEY are set as environment variables\n    chatkit_api_key = os.environ.get(\"CHATKIT_API_KEY\", \"\")\n    openai_api_key = os.environ.get(\"OPENAI_API_KEY\", \"\")\n\n    if not chatkit_api_key or not openai_api_key:\n        print(\"Please set CHATKIT_API_KEY and OPENAI_API_KEY environment variables.\")\n        print(\"You can obtain these from your respective dashboards (OpenAI and ChatKit). Exiting.\")\n        return\n\n    client = ChatKitClient(api_key=chatkit_api_key, openai_api_key=openai_api_key)\n    agent_name = \"my-chatkit-quickstart-agent\"\n\n    # Create or update a simple agent definition\n    agent = BasicChatKitAgent(\n        name=agent_name,\n        model=\"gpt-4o\", # Recommended to use a recent model\n        instructions=\"You are a helpful, concise assistant. Respond briefly to questions.\"\n    )\n    # This method handles creation if the agent doesn't exist, or updates it if it does.\n    await client.create_agent(agent)\n    print(f\"Agent '{agent_name}' is ready.\")\n\n    user_message = TextMessage(content=\"What is the capital of France?\")\n    print(f\"\\nUser: {user_message.content}\")\n\n    # Interact with the agent\n    async for response_message in client.run_agent_message(\n        agent_name=agent_name,\n        message=user_message\n    ):\n        if isinstance(response_message, TextMessage):\n            print(f\"Agent: {response_message.content}\")\n        else:\n            # Handle other message types like FunctionCallMessage if needed\n            print(f\"Agent sent a non-text message: {type(response_message).__name__}\")\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n","lang":"python","description":"This quickstart demonstrates how to initialize the `ChatKitClient`, define and create a simple `BasicChatKitAgent`, and interact with it using text messages. It requires `CHATKIT_API_KEY` and `OPENAI_API_KEY` to be set as environment variables for authentication."},"warnings":[{"fix":"Regularly check the official documentation and GitHub releases for updates and adjust your code accordingly. For stability, consider pinning specific beta versions (`pip install agent-framework-chatkit==1.0.0bYYYYMMDD`) but be prepared to upgrade.","message":"The `agent-framework-chatkit` library is currently in beta. This means breaking changes to APIs, class structures, and behavior are frequent and may occur without major version bumps (e.g., within `1.0.0bX` releases).","severity":"breaking","affected_versions":"1.0.0b onwards"},{"fix":"Always use `from chatkit import ...` for importing library components, not `from agent_framework_chatkit import ...`.","message":"The PyPI package name is `agent-framework-chatkit`, but the top-level import for components is `chatkit` (e.g., `from chatkit import ChatKitClient`). Directly importing from `agent_framework_chatkit` will result in a `ModuleNotFoundError`.","severity":"gotcha","affected_versions":"All beta versions"},{"fix":"Ensure both environment variables `CHATKIT_API_KEY` and `OPENAI_API_KEY` are correctly set with valid keys obtained from OpenAI and ChatKit, respectively.","message":"Both `CHATKIT_API_KEY` (for ChatKit service) and `OPENAI_API_KEY` (for underlying OpenAI models) are required for full functionality. Misconfigured or missing keys will lead to authentication failures.","severity":"gotcha","affected_versions":"All beta versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Correct the import statement. For example, change `from agent_framework_chatkit import ChatKitClient` to `from chatkit import ChatKitClient`.","cause":"Attempted to import library components using the PyPI package name (`agent_framework_chatkit`) instead of the correct import root (`chatkit`).","error":"ModuleNotFoundError: No module named 'agent_framework_chatkit'"},{"fix":"Verify that your `OPENAI_API_KEY` environment variable is correctly set with a valid OpenAI API key. This key is used by the underlying language models.","cause":"The `OPENAI_API_KEY` environment variable is either missing, empty, or contains an invalid key.","error":"openai.AuthenticationError: Incorrect API key provided"},{"fix":"Ensure your `CHATKIT_API_KEY` environment variable is correctly set with a valid ChatKit API key. This key is for authenticating with the ChatKit service itself.","cause":"The `CHATKIT_API_KEY` environment variable is either missing, empty, or contains an invalid key, preventing authentication with the ChatKit service.","error":"ChatKit API returned an error: Unauthorized"},{"fix":"Update to the latest beta version (`pip install --upgrade agent-framework-chatkit`) and consult the official documentation for the current API methods and usage patterns.","cause":"The API method being called may have changed or been removed due to the library's beta status, or an outdated version of the library is installed.","error":"AttributeError: 'ChatKitClient' object has no attribute 'run_agent_message' (or similar method not found)"}],"ecosystem":"pypi"}