semantic-kernel 1.43.1
pip install semantic-kernel
Released:
Semantic Kernel Python SDK
Navigation
Verified details
These details have been verified by PyPIMaintainers
π Avatar for alliscode from gravatar.comalliscode π Avatar for edvan_msft from gravatar.com
edvan_msft π Avatar for microsoft from gravatar.com
microsoft π Avatar for moonbox3 from gravatar.com
moonbox3
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: MIT License
- Author: Microsoft
- Requires: Python >=3.10
-
Provides-Extra:
anthropic,autogen,aws,azure,chroma,copilotstudio,faiss,google,hugging-face,mcp,milvus,mistralai,mongo,notebooks,ollama,onnx,oracledb,pandas,pinecone,postgres,qdrant,realtime,redis,sql,usearch,weaviate
Classifiers
- Development Status
- Framework
- Intended Audience
- License
- Programming Language
- Typing
Project description
Get Started with Semantic Kernel Python
[!IMPORTANT] Semantic Kernel is now Microsoft Agent Framework! Microsoft Agent Framework (MAF) is the enterpriseβready successor to Semantic Kernel. Microsoft Agent Framework is now available at version 1.0 as a production-ready release: stable APIs, and a commitment to long-term support. Whether you're building a single assistant or orchestrating a fleet of specialized agents, Microsoft Agent Framework 1.0 gives you enterprise-grade multi-agent orchestration, multi-provider model support, and cross-runtime interoperability via A2A and MCP.
Learn more about Semantic Kernel and Agent Framework here: Semantic Kernel and Microsoft Agent Framework on the Agent Framework blog, and try out the Semantic Kernel migration guide.
Highlights
- Flexible Agent Framework: build, orchestrate, and deploy AI agents and multi-agent systems
- Multi-Agent Systems: Model workflows and collaboration between AI specialists
- Plugin Ecosystem: Extend with Python, OpenAPI, Model Context Protocol (MCP), and more
- LLM Support: OpenAI, Azure OpenAI, Hugging Face, Mistral, Google AI, ONNX, Ollama, NVIDIA NIM, and others
- Vector DB Support: Azure AI Search, Elasticsearch, Chroma, and more
- Process Framework: Build structured business processes with workflow modeling
- Multimodal: Text, vision, audio
Quick Install
pipinstall--upgradesemantic-kernel # Optional: Add integrations pipinstall--upgradesemantic-kernel[hugging_face] pipinstall--upgradesemantic-kernel[all]
Supported Platforms:
- Python: 3.10+
- OS: Windows, macOS, Linux
1. Setup API Keys
Set as environment variables, or create a .env file at your project root:
OPENAI_API_KEY=sk-... OPENAI_CHAT_MODEL_ID=... ... AZURE_OPENAI_API_KEY=... AZURE_OPENAI_ENDPOINT=... AZURE_OPENAI_CHAT_DEPLOYMENT_NAME=... ...
You can also override environment variables by explicitly passing configuration parameters to the AI service constructor:
chat_service = AzureChatCompletion( api_key=..., endpoint=..., deployment_name=..., api_version=..., )
See the following setup guide for more information.
2. Use the Kernel for Prompt Engineering
Create prompt functions and invoke them via the Kernel:
importasyncio fromsemantic_kernelimport Kernel fromsemantic_kernel.connectors.ai.open_aiimport OpenAIChatCompletion fromsemantic_kernel.functionsimport KernelArguments kernel = Kernel() kernel.add_service(OpenAIChatCompletion()) prompt = """ 1) A robot may not injure a human being... 2) A robot must obey orders given it by human beings... 3) A robot must protect its own existence... Give me the TLDR in exactly {{$num_words}} words.""" async defmain(): result = await kernel.invoke_prompt(prompt, arguments=KernelArguments(num_words=5)) print(result) asyncio.run(main()) # Output: Protect humans, obey, self-preserve, prioritized.
3. Directly Use AI Services (No Kernel Required)
You can use the AI service classes directly for advanced workflows:
importasyncio importasyncio fromsemantic_kernel.connectors.ai.open_aiimport OpenAIChatCompletion, OpenAIChatPromptExecutionSettings fromsemantic_kernel.contentsimport ChatHistory async defmain(): service = OpenAIChatCompletion() settings = OpenAIChatPromptExecutionSettings() chat_history = ChatHistory(system_message="You are a helpful assistant.") chat_history.add_user_message("Write a haiku about Semantic Kernel.") response = await service.get_chat_message_content(chat_history=chat_history, settings=settings) print(response.content) """ Output: Thoughts weave through context, Semantic threads interlaceβ Kernel sparks meaning. """ asyncio.run(main())
4. Build an Agent with Plugins and Tools
Add Python functions as plugins or Pydantic models as structured outputs;
Enhance your agent with custom tools (plugins) and structured output:
importasyncio fromtypingimport Annotated frompydanticimport BaseModel fromsemantic_kernel.agentsimport ChatCompletionAgent fromsemantic_kernel.connectors.ai.open_aiimport AzureChatCompletion, OpenAIChatPromptExecutionSettings fromsemantic_kernel.functionsimport kernel_function, KernelArguments classMenuPlugin: @kernel_function(description="Provides a list of specials from the menu.") defget_specials(self) -> Annotated[str, "Returns the specials from the menu."]: return """ Special Soup: Clam Chowder Special Salad: Cobb Salad Special Drink: Chai Tea """ @kernel_function(description="Provides the price of the requested menu item.") defget_item_price( self, menu_item: Annotated[str, "The name of the menu item."] ) -> Annotated[str, "Returns the price of the menu item."]: return "$9.99" classMenuItem(BaseModel): # Used for structured outputs price: float name: str async defmain(): # Configure structured outputs format settings = OpenAIChatPromptExecutionSettings() settings.response_format = MenuItem # Create agent with plugin and settings agent = ChatCompletionAgent( service=AzureChatCompletion(), name="SK-Assistant", instructions="You are a helpful assistant.", plugins=[MenuPlugin()], arguments=KernelArguments(settings), ) response = await agent.get_response("What is the price of the soup special?") print(response.content) # Output: # The price of the Clam Chowder, which is the soup special, is $9.99. asyncio.run(main())
You can explore additional getting started agent samples here.
5. Multi-Agent Orchestration
Coordinate a group of agents to iteratively solve a problem or refine content together:
importasyncio fromsemantic_kernel.agentsimport ChatCompletionAgent, GroupChatOrchestration, RoundRobinGroupChatManager fromsemantic_kernel.agents.runtimeimport InProcessRuntime fromsemantic_kernel.connectors.ai.open_aiimport AzureChatCompletion defget_agents(): return [ ChatCompletionAgent( name="Writer", instructions="You are a creative content writer. Generate and refine slogans based on feedback.", service=AzureChatCompletion(), ), ChatCompletionAgent( name="Reviewer", instructions="You are a critical reviewer. Provide detailed feedback on proposed slogans.", service=AzureChatCompletion(), ), ] async defmain(): agents = get_agents() group_chat = GroupChatOrchestration( members=agents, manager=RoundRobinGroupChatManager(max_rounds=5), ) runtime = InProcessRuntime() runtime.start() result = await group_chat.invoke( task="Create a slogan for a new electric SUV that is affordable and fun to drive.", runtime=runtime, ) value = await result.get() print(f"Final Slogan: {value}") # Example Output: # Final Slogan: "Feel the Charge: Adventure Meets Affordability in Your New Electric SUV!" await runtime.stop_when_idle() if __name__ == "__main__": asyncio.run(main())
For orchestration-focused examples, see these orchestration samples.
More Examples & Notebooks
- Getting Started with Agents: Practical agent orchestration and tool use
- Getting Started with Processes: Modeling structured workflows with the Process framework
- Concept Samples: Advanced scenarios, integrations, and SK patterns
- Getting Started Notebooks: Interactive Python notebooks for rapid experimentation
Semantic Kernel Documentation
Project details
Verified details
These details have been verified by PyPIMaintainers
π Avatar for alliscode from gravatar.comalliscode π Avatar for edvan_msft from gravatar.com
edvan_msft π Avatar for microsoft from gravatar.com
microsoft π Avatar for moonbox3 from gravatar.com
moonbox3
Unverified details
These details have not been verified by PyPIProject links
Meta
- License: MIT License
- Author: Microsoft
- Requires: Python >=3.10
-
Provides-Extra:
anthropic,autogen,aws,azure,chroma,copilotstudio,faiss,google,hugging-face,mcp,milvus,mistralai,mongo,notebooks,ollama,onnx,oracledb,pandas,pinecone,postgres,qdrant,realtime,redis,sql,usearch,weaviate
Classifiers
- Development Status
- Framework
- Intended Audience
- License
- Programming Language
- Typing
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file semantic_kernel-1.43.1.tar.gz.
File metadata
- Download URL: semantic_kernel-1.43.1.tar.gz
- Upload date:
- Size: 617.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29aac381d31ce06cf06de88a71fc2ebfe2947690f2ed33ceeb497a35fd3310ea
|
|
| MD5 |
8f6f2f06c90082cf8e5208bb270c76b0
|
|
| BLAKE2b-256 |
55da24117fb9dc10ff3b9714b7193f99a8a414acf7a6f251102caca98e17b72d
|
File details
Details for the file semantic_kernel-1.43.1-py3-none-any.whl.
File metadata
- Download URL: semantic_kernel-1.43.1-py3-none-any.whl
- Upload date:
- Size: 929.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
371b832be8ae2b36cfaec2445337905933d2d6514ae07b62fb69fe428a910eb7
|
|
| MD5 |
ec8abb8ad8d4b972b83df58815e9feee
|
|
| BLAKE2b-256 |
8f473e581e6c3fc98e0b5dea16400efd6c8eb3b8a6d227d6760957d592678e15
|
