A complete example combining all auth features in one agent: API key auth for HTTP, allowlist auth for messaging interfaces, composite auth for combining providers, and per-trigger overrides.
from definable.agent import Agentfrom definable.agent.auth import APIKeyAuth, AllowlistAuth, CompositeAuthfrom definable.model.openai import OpenAIChatagent = Agent( model=OpenAIChat(id="gpt-4o"),)# Composite auth: API keys for HTTP + allowlist for Telegramagent.auth = CompositeAuth( APIKeyAuth(keys={"sk-my-api-key"}), AllowlistAuth( user_ids={"telegram-user-123", "telegram-user-456"}, platforms={"telegram"}, ),)# Public webhook (no auth)@agent.on(Webhook("/public-hook", auth=False))async def public_endpoint(event): return "Public response"# Auth context in hooks@agent.before_requestasync def log_auth(context): if hasattr(context, "auth") and context.auth: print(f"Authenticated: {context.auth.user_id}")agent.serve(port=8000)