Google Calendar
Query events, check availability, and create meetings.
Query events, check availability, and create meetings. By default, exposes query_calendar for reading. Enable write=True to also expose update_calendar for creating and modifying events.
Create a virtual environment, then install the Google Workspace clients and the model SDK:
uv pip install -U agno openai google-api-python-client google-auth-httplib2 google-auth-oauthlib
export OPENAI_API_KEY="your-openai-api-key"For the personal OAuth example, enable the relevant Google API in your Cloud project, configure its consent screen, and create a Desktop OAuth client. Set GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET and GOOGLE_PROJECT_ID using that client. Authorize access in the browser on first use. The authentication section below also covers service accounts.
For a headless service, provision credentials first and set GOOGLE_OAUTH_NONINTERACTIVE=1. Gmail and Calendar also accept auth=AuthConfig(interactive=False) from agno.tools.google.auth; the current Drive provider does not accept auth=. If credentials cannot be loaded or refreshed, authentication reports an error instead of opening a browser. Provider configuration selects the credentials; forwarding a run’s user ID does not switch Google accounts.
Save as calendar_context.py and run python calendar_context.py after configuring authentication:
import asyncio
from agno.agent import Agent
from agno.context.calendar import GoogleCalendarContextProvider
from agno.models.openai import OpenAIResponses
async def main():
calendar = GoogleCalendarContextProvider(model=OpenAIResponses(id="gpt-5.4-mini"))
agent = Agent(
model=OpenAIResponses(id="gpt-5.4"),
tools=calendar.get_tools(),
instructions=calendar.instructions(),
)
await agent.aprint_response("What meetings do I have tomorrow?")
if __name__ == "__main__":
asyncio.run(main())Authentication
Same as Gmail - OAuth or service account.
export GOOGLE_CLIENT_ID=...
export GOOGLE_CLIENT_SECRET=...
export GOOGLE_PROJECT_ID=...Token cached to calendar_token.json.
export GOOGLE_SERVICE_ACCOUNT_FILE=/path/to/service-account.json
export GOOGLE_DELEGATED_USER=user@domain.com # OptionalWithout delegated_user, use a calendar shared with the service account and pass its ID as calendar_id; do not assume that primary identifies a provisioned personal calendar. Domain-wide delegation requires an administrator to grant the required scopes.
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
id | str | "calendar" | Tools become query_<id> and update_<id>. |
calendar_id | str | "primary" | Calendar to query and modify. Set to a shared or team calendar ID instead of the caller's own calendar. |
model | Model | None | Model for sub-agents. |
read | bool | True | Expose query_calendar. |
write | bool | False | Expose update_calendar. Disabled by default for safety. |
mode | ContextMode | default | See Mode. |
The read/write flags below describe the default tool surface. See read/write control for mode and authorization boundaries.
Tools Exposed
| Tool | Description |
|---|---|
query_calendar | List events, search events, check availability, find free slots. Exposed when read=True (default). |
update_calendar | Create events, update events, delete events. Requires write=True. |
Example queries
| Query | What happens |
|---|---|
| "What's on my calendar this week?" | Lists events with time range |
| "When am I free on Friday afternoon?" | Checks availability |
| "Find all meetings about the product launch" | Searches event titles/descriptions |
| "Schedule a 30-min sync with Alice tomorrow at 2pm" | Creates event (requires write=True) |