CopilotKit/CopilotKit · error · HTTPException
{key} is required
Error message
{key} is required What it means
Error "{key} is required" thrown in CopilotKit/CopilotKit.
Source
Thrown at sdk-python/copilotkit/integrations/fastapi.py:73
future = loop.run_in_executor(executor, run_handler_in_thread, request, sdk)
return await future
return await handler(request, sdk)
# Ensure the prefix starts with a slash and remove trailing slashes
normalized_prefix = "/" + prefix.strip("/")
fastapi_app.add_api_route(
f"{normalized_prefix}/{{path:path}}",
make_handler,
methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"],
)
def body_get_or_raise(body: Any, key: str):
"""Get value from body or raise an error"""
value = body.get(key)
if value is None:
raise HTTPException(status_code=400, detail=f"{key} is required")
return value
async def handler(request: Request, sdk: CopilotKitRemoteEndpoint):
"""Handle FastAPI request"""
try:
body = await request.json()
except: # pylint: disable=bare-except
body = None
# Propagate x-aimock-* headers to outgoing LLM calls via ContextVar
set_forwarded_headers(dict(request.headers))
path = request.path_params.get("path")
method = request.method
context = cast(
CopilotKitContext,View on GitHub (pinned to 68fbe97d87)
When it happens
Trigger: Thrown at sdk-python/copilotkit/integrations/fastapi.py:73 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of CopilotKit/CopilotKit@68fbe97d87 (2026-08-27).
Data as JSON: /api/errors/9385d2a7bdcf19d3.
Report an issue: GitHub.