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
muslpy 3.10–3.940 runs
installs and imports cleanly · install 0.0s · import 0.000s · 75.3MB
glibcpy 3.10–3.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.")
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.