Registry / llm-agents / copilotkit

copilotkit

JSON →
library0.1.94pypypiunverified

CopilotKit is a framework for building AI Copilots that can deeply integrate with your product's UI. The Python SDK allows you to define AI tools and integrate them into an agent runtime, typically exposed via a web framework like FastAPI. It is currently in version 0.1.87 and is part of a larger, actively developed ecosystem, with the Python SDK evolving rapidly.

pip install copilotkit
INSTALL
IMPORT
SIG · COPILOTKIT
C
copilotkit
llm-agentspythonv0.1.94
Install
9.9s avg
Import
Disk
93MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.94 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.940 runs
installs and imports cleanly · install 0.0s · import 0.000s · 75.3MB
glibc
py 3.103.940 runs
installs and imports cleanly · install 9.9s · import 0.000s · 83MB
93MB installed
● package 93MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CopilotKit
from copilotkit import CopilotKit
from copilotkit import CopilotKit

This quickstart demonstrates how to initialize a `CopilotKit` application, define and register a tool, and expose it via a FastAPI server. It requires `fastapi` and `uvicorn` to be installed (e.g., `pip install "copilotkit[fastapi]"`). The `OPENAI_API_KEY` environment variable is necessary for the underlying OpenAI client.

import os from openai import OpenAI from copilotkit import CopilotKit, tool from copilotkit.fastapi import CopilotKitFastAPI from fastapi import FastAPI import uvicorn # Ensure OPENAI_API_KEY is set in environment or .env file openai_api_key = os.environ.get("OPENAI_API_KEY", "") if not openai_api_key: print("Warning: OPENAI_API_KEY not found. Please set it as an environment variable.") # For demonstration, we'll continue, but real usage would require a key. # Initialize OpenAI client (requires openai>=1.0.0) openai_client = OpenAI(api_key=openai_api_key) # Create a CopilotKit app instance app = CopilotKit(openai_client=openai_client) # Define a tool using the @tool decorator @tool def get_current_weather(location: str, unit: str = "fahrenheit") -> dict: """Get the current weather in a given location. Args: location (str): The city and state, e.g. "San Francisco, CA" unit (str, optional): The unit of temperature. Defaults to "fahrenheit". Returns: dict: A dictionary containing temperature and unit. """ print(f"Tool called: get_current_weather for {location} in {unit}") if "san francisco" in location.lower(): return {"temperature": "70", "unit": unit} elif "new york" in location.lower(): return {"temperature": "60", "unit": unit} else: return {"temperature": "unknown", "unit": unit} # Register the tool with the CopilotKit app app.register_tool(get_current_weather) # Integrate with FastAPI to expose the CopilotKit app fast_app = FastAPI() fast_app.include_router(CopilotKitFastAPI(app)) @fast_app.get("/health") async def health_check(): return {"status": "ok"} # To run this example: # 1. Save the code above as `main.py`. # 2. Install the necessary dependencies: `pip install "copilotkit[fastapi]"`. # 3. Set your OpenAI API key: `export OPENAI_API_KEY="your_key_here"` (or use a .env file). # 4. Run the FastAPI application using Uvicorn from your terminal: # `uvicorn main:fast_app --reload --port 8000` # Your CopilotKit backend will then be accessible at http://localhost:8000/copilotkit print("CopilotKit app configured. Use `uvicorn main:fast_app --reload --port 8000` to run.")
Debug
Known issues
gotchaThe CopilotKit Python SDK (v0.1.x) is at an earlier development stage compared to the JavaScript/TypeScript frontend SDKs (v1.x). This may lead to feature disparities or slower adoption of new features from the broader CopilotKit ecosystem.
fix
Refer to the Python SDK's specific documentation and examples on GitHub for supported features. Align expectations with the current Python SDK version.
affects: 0.1.0 - 0.1.87
gotchaTool definition relies heavily on Python type hints. Without accurate type hints for function arguments and return types, the underlying LLM may fail to correctly interpret the tool's schema, leading to incorrect or failed tool calls.
fix
Always provide precise type hints for all arguments and the return type of functions decorated with `@tool`.
affects: All
gotchaThe `CopilotKit` app is designed to be integrated into a web framework (like FastAPI), not run as a standalone Python script that serves HTTP requests directly. Attempts to call the `CopilotKit` instance as a server will fail.
fix
Use the provided framework integrations, such as `CopilotKitFastAPI` for FastAPI, to expose your CopilotKit app via a standard web server like Uvicorn.
affects: All
deprecatedPython 3.9 and older versions are not officially supported. The `requires_python` spec is `<3.13,>=3.10`.
fix
Ensure your environment uses Python 3.10, 3.11, or 3.12.
affects: <=0.1.87
Upgrade
Version history
0.1.94latest on PyPI · released Jun 4, 2026
Audit
Dependencies
openairequiredRequired for interacting with OpenAI's LLMs.
python-dotenvrequiredRecommended for managing environment variables.
fastapioptionalRequired for the `copilotkit.fastapi` integration to expose tools.
uvicornoptionalASGI server for running FastAPI applications.
Agent activity
36 hits · last 30 days
node
34
OpenAI (training)
1
Resources
copilotkit — pip install copilotkit · libregistry