AutoKitteh Python SDK Documentation

Module contents

AutoKitteh Python SDK.

class autokitteh.AttrDict

Bases: dict

Allow attribute access to dictionary keys.

>>> config = AttrDict({'server': {'port': 8080}, 'debug': True})
>>> config.server.port
8080
>>> config.debug
True
>>> config["debug"]
True
exception autokitteh.AutoKittehError(*args)

Bases: Exception

Generic base class for all errors in the AutoKitteh SDK.

class autokitteh.Event(data: AttrDict, event_id: str | None, event_type: str | None)

Bases: object

AutoKitteh Event.

data: AttrDict
event_id: str | None

None if manual start

event_type: str | None

None if manual start

class autokitteh.Signal(name: str, payload: <built-in function any> = None)

Bases: object

name: str
payload: any = None
autokitteh.activity(fn: callable) callable

Decorator to mark a function as a Temporal activity.

This forces AutoKitteh to run the function as a single Temporal activity, instead of a sequence of activities within a Temporal workflow.

Use this decorator when you want to run functions with input arguments and/or return values that are not compatible with pickle.

For more details, see: https://docs.python.org/3/library/pickle.html#what-can-be-pickled-and-unpickled

autokitteh.add_values(key: str, value: int | float) int | float

Add to a stored value.

This operation is atomic.

If key is not found, its initial value is set to the provided value.

Works both for durable and non-durable sessions.

Parameters:
  • key – Key of the value to set.

  • value – Value to add. Value must be serializable.

Returns:

New result value. Always the same type as the value stored under the key.

autokitteh.check_and_set_value(key: str, expected_value: Any, new_value: Any) bool

Check and set a stored value.

This operation is atomic.

Works both for durable and non-durable sessions.

Parameters:
  • key – Key of the value to set.

  • expected_value – Expected current value.

  • new_value – New value to store if the current value matches the expected value.

Returns:

True if the value was set, False otherwise.

Return type:

bool

autokitteh.del_value(key: str) None

Delete a stored value.

Works both for durable and non-durable sessions.

Parameters:

key – Key of the value to set.

Returns:

None.

autokitteh.get_store_public_url() str

Get the public URL of the cross-sessions published values store.

autokitteh.get_value(key: str) Any

Get a stored value.

Works both for durable and non-durable sessions.

Parameters:

key – Key of the value to retrieve.

Returns:

The stored value, or None if not found.

Return type:

Any

autokitteh.get_webhook_url(trigger_name: str) str
autokitteh.http_outcome(status_code: int = 200, *, body: Any = None, json: Any = None, headers: dict[str, str] = {}, more: bool = False, event_id: str | None = None) None

Respond to an HTTP request.

Works both in durable and nondurable sessions.

Parameters:
  • status_code – HTTP status code to return. Ignored if not the first response to a request.

  • body – body to return. If it is a dict or a list, it will be serialized as JSON. If it is a string or bytes, it will be returned as-is.

  • json – JSON-serializable value to return as JSON. If specified, the Content-Type header will be set to application/json. Cannot be used together with body.

  • headers – dict of headers to return.

  • more – If True, indicates that more responses will follow for this request.

  • event_id – Optional event ID to associate the outcome with.

autokitteh.inhibit_activities(fn: callable) callable

Decorator to inhibit the execution of Temporal activities.

Functions using this decorator will not spawn activities even if otherwise activities should have been launched. This is useful for performing operations that are required to run even on replay (such as various clients creation) and are completely deterministic. The function results are not cached and would be rerun in case of replay.

CAVEAT: Do not use this on functions that take a long time to run (more than a second), as they will cause the workflow to timeout.

autokitteh.list_values_keys() list[str]

List all stored keys.

Works both for durable and non-durable sessions.

Returns:

Sorted list of all keys in the store.

Return type:

list[str]

autokitteh.mutate_value(key: str, op: Op, *args: list[Any]) Any

Mutate a stored value.

Works both for durable and non-durable sessions.

Parameters:
  • key – Key of the value to mutate.

  • op – Operation to perform on the value.

  • args – Additional arguments for the operation.

Returns:

Result of the operation, if applicable.

Return type:

Any

Raises:

AutoKittehError – Value is too large.

autokitteh.next_event(subscription_id: str | list[str], *, timeout: timedelta | int | float | None = None, full: bool = False) AttrDict | Event | None

Get the next event from the subscription(s).

If timeout is not None and there are no new events after timeout, this function will return None.

If full is True, returns the full Event object, otherwise returns only the event data.

Works both in durable and nondurable sessions.

autokitteh.next_signal(name: str | list[str], *, timeout: timedelta | int | float | None = None) Signal | None

Get the next signal.

Cannot be used in an activity. Works only for durable sessions.

autokitteh.outcome(v: Any, *, event_id: str | None = None) None

Log an outcome for the current session.

Works both in durable and nondurable sessions.

Parameters:
  • v – The outcome value. Can be any JSON-serializable value.

  • event_id – Optional event ID to associate the outcome with.

autokitteh.publish_value(key: str) None

Publish a stored value.

Works both for durable and non-durable sessions.

Parameters:

key – Key of the value to publish.

autokitteh.register_no_activity(items: list[Callable]) None

Mark items that should not run as activities.

Items should be callable and hashable. If an item is a class, all methods in the class are marked as non-activities.

This helps speeding up your code, but you might risk non-deterministic behavior.

autokitteh.set_value(key: str, value: Any) None

Set a stored value.

Works both for durable and non-durable sessions.

Parameters:
  • key – Key of the value to set.

  • value – Value to store. If Value is None, it will be deleted. Value must be serializable.

Returns:

None.

Raises:

AutoKittehError – Value is too large.

autokitteh.signal(session_id: str, name: str, payload: any = None) None

Signal a session.

Works both for durable and non-durable sessions. Note that only durable sessions can receive signals.

autokitteh.start(loc: str, data: dict | None = None, memo: dict | None = None, project: str = '') str

Start a new session.

Works both in durable and nondurable sessions.

Sessions started this way will have the same durability setting as the parent session.

autokitteh.subscribe(source: str, filter: str = '') str

Subscribe to events on connections or triggers. Optional filter is a CEL expression.

Works both in durable and nondurable sessions.

autokitteh.unpublish_value(key: str) None

Unpublish a stored value.

Works both for durable and non-durable sessions.

Parameters:

key – Key of the value to unpublish.

autokitteh.unsubscribe(subscription_id: str) None

Unsubscribe from events.

Works both in durable and nondurable sessions.

Submodules

autokitteh.activities module

Decorator to mark a function as a Temporal activity.

autokitteh.activities.activity(fn: callable) callable

Decorator to mark a function as a Temporal activity.

This forces AutoKitteh to run the function as a single Temporal activity, instead of a sequence of activities within a Temporal workflow.

Use this decorator when you want to run functions with input arguments and/or return values that are not compatible with pickle.

For more details, see: https://docs.python.org/3/library/pickle.html#what-can-be-pickled-and-unpickled

autokitteh.activities.inhibit_activities(fn: callable) callable

Decorator to inhibit the execution of Temporal activities.

Functions using this decorator will not spawn activities even if otherwise activities should have been launched. This is useful for performing operations that are required to run even on replay (such as various clients creation) and are completely deterministic. The function results are not cached and would be rerun in case of replay.

CAVEAT: Do not use this on functions that take a long time to run (more than a second), as they will cause the workflow to timeout.

autokitteh.activities.register_no_activity(items: list[Callable]) None

Mark items that should not run as activities.

Items should be callable and hashable. If an item is a class, all methods in the class are marked as non-activities.

This helps speeding up your code, but you might risk non-deterministic behavior.

autokitteh.microsoft module

Initialize Microsoft Graph SDK clients, based on AutoKitteh connections.

class autokitteh.microsoft.OAuthTokenProvider(connection: str, buffer_time: timedelta | None = None)

Bases: TokenCredential

OAuth 2.0 token wrapper for Microsoft Graph clients.

get_token(*scopes: str, **kwargs) AccessToken

Request an access token for scopes.

Parameters:

scopes (str) – The type of access needed.

Keyword Arguments:
  • claims (str) – Additional claims required in the token, such as those returned in a resource provider’s claims challenge following an authorization failure.

  • tenant_id (str) – Optional tenant to include in the token request.

  • enable_cae (bool) – Indicates whether to enable Continuous Access Evaluation (CAE) for the requested token. Defaults to False.

Return type:

AccessToken

Returns:

An AccessToken instance containing the token string and its expiration time in Unix time.

autokitteh.microsoft.teams_client(connection: str, **kwargs) GraphServiceClient

Initialize a Microsoft Teams client, based on an AutoKitteh connection.

API documentation: https://docs.autokitteh.com/integrations/microsoft/teams/python

Parameters:

connection – AutoKitteh connection name.

Returns:

Microsoft Graph client.

Raises:
  • ValueError – AutoKitteh connection name or auth type are invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

  • OAuthRefreshError – OAuth token refresh failed.

autokitteh.store module

class autokitteh.store.Op(*values)

Bases: StrEnum

Enum for operation types.

ADD = 'add'
CHECK_AND_SET = 'check_and_set'
DEL = 'del'
GET = 'get'
SET = 'set'
class autokitteh.store.Store

Bases: MutableMapping

Store it a dict like interface to ak store.

Note that read-modify-write operations are not atomic.

Values must be pickleable, see https://docs.python.org/3/library/pickle.html#what-can-be-pickled-and-unpickled

Works both for durable and non-durable sessions.

autokitteh.store.add_values(key: str, value: int | float) int | float

Add to a stored value.

This operation is atomic.

If key is not found, its initial value is set to the provided value.

Works both for durable and non-durable sessions.

Parameters:
  • key – Key of the value to set.

  • value – Value to add. Value must be serializable.

Returns:

New result value. Always the same type as the value stored under the key.

autokitteh.store.check_and_set_value(key: str, expected_value: Any, new_value: Any) bool

Check and set a stored value.

This operation is atomic.

Works both for durable and non-durable sessions.

Parameters:
  • key – Key of the value to set.

  • expected_value – Expected current value.

  • new_value – New value to store if the current value matches the expected value.

Returns:

True if the value was set, False otherwise.

Return type:

bool

autokitteh.store.del_value(key: str) None

Delete a stored value.

Works both for durable and non-durable sessions.

Parameters:

key – Key of the value to set.

Returns:

None.

autokitteh.store.get_store_public_url() str

Get the public URL of the cross-sessions published values store.

autokitteh.store.get_value(key: str) Any

Get a stored value.

Works both for durable and non-durable sessions.

Parameters:

key – Key of the value to retrieve.

Returns:

The stored value, or None if not found.

Return type:

Any

autokitteh.store.list_values_keys() list[str]

List all stored keys.

Works both for durable and non-durable sessions.

Returns:

Sorted list of all keys in the store.

Return type:

list[str]

autokitteh.store.mutate_value(key: str, op: Op, *args: list[Any]) Any

Mutate a stored value.

Works both for durable and non-durable sessions.

Parameters:
  • key – Key of the value to mutate.

  • op – Operation to perform on the value.

  • args – Additional arguments for the operation.

Returns:

Result of the operation, if applicable.

Return type:

Any

Raises:

AutoKittehError – Value is too large.

autokitteh.store.publish_value(key: str) None

Publish a stored value.

Works both for durable and non-durable sessions.

Parameters:

key – Key of the value to publish.

autokitteh.store.set_value(key: str, value: Any) None

Set a stored value.

Works both for durable and non-durable sessions.

Parameters:
  • key – Key of the value to set.

  • value – Value to store. If Value is None, it will be deleted. Value must be serializable.

Returns:

None.

Raises:

AutoKittehError – Value is too large.

autokitteh.store.unpublish_value(key: str) None

Unpublish a stored value.

Works both for durable and non-durable sessions.

Parameters:

key – Key of the value to unpublish.

autokitteh.signals module

Send and receive signals.

class autokitteh.signals.Signal(name: str, payload: <built-in function any> = None)

Bases: object

name: str
payload: any = None
autokitteh.signals.next_signal(name: str | list[str], *, timeout: timedelta | int | float | None = None) Signal | None

Get the next signal.

Cannot be used in an activity. Works only for durable sessions.

autokitteh.signals.signal(session_id: str, name: str, payload: any = None) None

Signal a session.

Works both for durable and non-durable sessions. Note that only durable sessions can receive signals.

autokitteh.event module

AutoKitteh Event class

class autokitteh.event.Event(data: AttrDict, event_id: str | None, event_type: str | None)

Bases: object

AutoKitteh Event.

data: AttrDict
event_id: str | None

None if manual start

event_type: str | None

None if manual start

autokitteh.triggers module

Utility functions for triggers.

autokitteh.triggers.get_webhook_url(trigger_name: str) str

autokitteh.zoom module

Initialize a Zoom client, based on an AutoKitteh connection.

autokitteh.zoom.zoom_client(connection: str) Session

Initialize a Zoom client, based on an AutoKitteh connection.

API reference: https://developers.zoom.us/docs/api/

Parameters:

connection – AutoKitteh connection name.

Returns:

Requests session object.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

autokitteh.asana module

autokitteh.asana.asana_client(connection: str) ApiClient

Initialize an Asana client, based on an AutoKitteh connection.

API reference: https://developers.asana.com/docs/python

Parameters:

connection – AutoKitteh connection name.

Returns:

Asana client.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

autokitteh.oauth2_session module

class autokitteh.oauth2_session.OAuth2Session(integration: str, connection: str, *args, **kwargs)

Bases: BaseUrlSession

Encapsulates a requests session, based on an AutoKitteh connection.

  • Automatically sets the Authorization header with an OAuth token.

  • Automatically refreshes an OAuth token if a refresh token is initialized in the connection.

autokitteh.events module

Un/subscribe and consume AutoKitteh connection events.

autokitteh.events.next_event(subscription_id: str | list[str], *, timeout: timedelta | int | float | None = None, full: bool = False) AttrDict | Event | None

Get the next event from the subscription(s).

If timeout is not None and there are no new events after timeout, this function will return None.

If full is True, returns the full Event object, otherwise returns only the event data.

Works both in durable and nondurable sessions.

autokitteh.events.start(loc: str, data: dict | None = None, memo: dict | None = None, project: str = '') str

Start a new session.

Works both in durable and nondurable sessions.

Sessions started this way will have the same durability setting as the parent session.

autokitteh.events.subscribe(source: str, filter: str = '') str

Subscribe to events on connections or triggers. Optional filter is a CEL expression.

Works both in durable and nondurable sessions.

autokitteh.events.unsubscribe(subscription_id: str) None

Unsubscribe from events.

Works both in durable and nondurable sessions.

autokitteh.salesforce module

Initialize a Salesforce client, based on an AutoKitteh connection.

autokitteh.salesforce.salesforce_client(connection: str, **kwargs) Salesforce

Initialize a Salesforce client, based on an AutoKitteh connection.

Parameters:

connection – AutoKitteh connection name.

Returns:

Salesforce client.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

  • SalesforceApiError – Connection attempt failed, or connection is unauthorized.

autokitteh.hubspot module

Initialize a HubSpot client, based on an AutoKitteh connection.

autokitteh.hubspot.hubspot_client(connection: str, **kwargs) HubSpot

Initialize a HubSpot client, based on an AutoKitteh connection.

Parameters:

connection – AutoKitteh connection name.

Returns:

HubSpot SDK client.

Raises:

autokitteh.linear module

Initialize a Linear client, based on an AutoKitteh connection.

autokitteh.linear.linear_client(connection: str) Session

Initialize a Linear client, based on an AutoKitteh connection.

API reference: https://linear.app/developers/graphql

Parameters:

connection – AutoKitteh connection name.

Returns:

Requests session object.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

autokitteh.telegram module

Initialize a Telegram client, based on an AutoKitteh connection.

autokitteh.telegram.telegram_client(connection: str) Bot

Initialize a Telegram client, based on an AutoKitteh connection.

API reference:

https://github.com/python-telegram-bot/python-telegram-bot https://core.telegram.org/bots/api https://core.telegram.org/bots/samples

Parameters:

connection – AutoKitteh connection name.

Returns:

Telegram Bot API client.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

  • telegram.error.TelegramError – Telegram SDK initialization errors.

autokitteh.azurebot module

Initialize a AzureBot client, based on an AutoKitteh connection.

class autokitteh.azurebot.AzureBotClient(connection: str)

Bases: object

send_conversation_activity(activity: dict, conversation_id: str | None, service_url: str = 'https://smba.trafficmanager.net/teams/') Any

Send activity synchronously.

If this is sent as a reply to an event, use the service_url from that event.

Raises on non-2xx statuses.

Returns the HTTP response body as JSON.

autokitteh.azurebot.azurebot_client(connection: str) AzureBotClient

autokitteh.attr_dict module

Helper class to allow attribute access to dictionary keys.

class autokitteh.attr_dict.AttrDict

Bases: dict

Allow attribute access to dictionary keys.

>>> config = AttrDict({'server': {'port': 8080}, 'debug': True})
>>> config.server.port
8080
>>> config.debug
True
>>> config["debug"]
True

autokitteh.airtable module

Initialize an Airtable client, based on an AutoKitteh connection.

autokitteh.airtable.airtable_client(connection: str) Api

Initialize an Airtable client, based on an AutoKitteh connection.

API reference: https://pyairtable.readthedocs.io/en/stable/getting-started.html https://github.com/gtalarico/pyairtable

Parameters:

connection – AutoKitteh connection name.

Returns:

Requests session object.

Raises:

autokitteh.discord module

autokitteh.discord.bot_token(connection: str)
autokitteh.discord.discord_client(connection: str, intents=None, **kwargs) Client

Initialize a Discord client, based on an AutoKitteh connection.

API reference: https://discordpy.readthedocs.io/en/stable/api.html

Parameters:
  • connection – AutoKitteh connection name.

  • intents – An object representing the events your bot can receive.

Returns:

Discord client.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

  • DiscordException – Connection attempt failed, or connection is unauthorized.

autokitteh.slack_test module

Unit tests for the “slack” module.

autokitteh.slack_test.test_normalize_channel_name()

autokitteh.connections module

AutoKitteh connection-related utilities.

autokitteh.connections.check_connection_name(connection: str) None

Check that the given AutoKitteh connection name is valid.

Parameters:

connection – AutoKitteh connection name.

Raises:

ValueError – The connection name is invalid.

autokitteh.connections.encode_jwt(payload: dict[str, int], connection: str, algorithm: str) str

Mock function to generate JWTs, overridden by the AutoKitteh runner.

autokitteh.connections.refresh_oauth(integration: str, connection: str) tuple[str, datetime]

Mock function to refresh OAuth tokens, overridden by the AutoKitteh runner.

autokitteh.google module

Initialize Google API clients, based on AutoKitteh connections.

autokitteh.google.gemini_client(connection: str, **kwargs) GenerativeModel

Initialize a Gemini generative AI client, based on an AutoKitteh connection.

API reference: - https://ai.google.dev/gemini-api/docs - https://github.com/google-gemini/generative-ai-python/blob/main/docs/api/google/generativeai/GenerativeModel.md

Code samples: - https://ai.google.dev/gemini-api/docs#explore-the-api - https://ai.google.dev/gemini-api/docs/text-generation?lang=python - https://github.com/google-gemini/generative-ai-python/tree/main/samples - https://github.com/google-gemini/cookbook

Parameters:

connection – AutoKitteh connection name.

Returns:

An initialized GenerativeModel instance.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

autokitteh.google.gmail_client(connection: str, **kwargs)

Initialize a Gmail client, based on an AutoKitteh connection.

API documentation: https://docs.autokitteh.com/integrations/google/gmail/python

Code samples: - https://github.com/autokitteh/kittehub/tree/main/samples/google/gmail - https://github.com/googleworkspace/python-samples/tree/main/gmail

Parameters:

connection – AutoKitteh connection name.

Returns:

Gmail client.

Raises:
autokitteh.google.google_calendar_client(connection: str, **kwargs)

Initialize a Google Calendar client, based on an AutoKitteh connection.

API documentation: https://docs.autokitteh.com/integrations/google/calendar/python

Code samples: https://github.com/autokitteh/kittehub/tree/main/samples/google/calendar

Parameters:

connection – AutoKitteh connection name.

Returns:

Google Calendar client.

Raises:
autokitteh.google.google_creds(integration: str, connection: str, scopes: list[str], **kwargs)

Initialize credentials for a Google APIs client, for service discovery.

This function supports both AutoKitteh connection modes: users (with OAuth 2.0), and GCP service accounts (with a JSON key).

Code samples: https://github.com/googleworkspace/python-samples

For subsequent usage details, see: https://googleapis.github.io/google-api-python-client/docs/epy/googleapiclient.discovery-module.html#build

Parameters:
  • integration – AutoKitteh integration name.

  • connection – AutoKitteh connection name.

  • scopes – List of OAuth permission scopes.

Returns:

Google API credentials, ready for usage in “googleapiclient.discovery.build()”.

Raises:
autokitteh.google.google_drive_client(connection: str, **kwargs)

Initialize a Google Drive client, based on an AutoKitteh connection.

API documentation: https://docs.autokitteh.com/integrations/google/drive/python

Code samples: https://github.com/googleworkspace/python-samples/tree/main/drive

Parameters:

connection – AutoKitteh connection name.

Returns:

Google Drive client.

Raises:
autokitteh.google.google_forms_client(connection: str, **kwargs)

Initialize a Google Forms client, based on an AutoKitteh connection.

API documentation: https://docs.autokitteh.com/integrations/google/forms/python

Code samples: - https://github.com/autokitteh/kittehub/tree/main/samples/google/forms - https://github.com/googleworkspace/python-samples/tree/main/forms

Parameters:

connection – AutoKitteh connection name.

Returns:

Google Forms client.

Raises:
autokitteh.google.google_id(url: str) str

Extract the Google Doc/Form/Sheet ID from a URL. This function is idempotent.

Example: ‘https://docs.google.com/…/d/1a2b3c4d5e6f/edit’ –> ‘1a2b3c4d5e6f’

autokitteh.google.google_pydantic_ai_provider(connection: str, **kwargs) GoogleProvider

Initialize a Gemini Pydantic AI provider, based on an AutoKitteh connection.

API reference:

https://ai.pydantic.dev/models/gemini

Parameters:

connection – AutoKitteh connection name.

Returns:

Google Pydantic AI provider.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

autokitteh.google.google_sheets_client(connection: str, **kwargs)

Initialize a Google Sheets client, based on an AutoKitteh connection.

API documentation: https://docs.autokitteh.com/integrations/google/sheets/python

Code samples: - https://github.com/autokitteh/kittehub/tree/main/samples/google/sheets - https://github.com/googleworkspace/python-samples/tree/main/sheets

Parameters:

connection – AutoKitteh connection name.

Returns:

Google Sheets client.

Raises:
autokitteh.google.gspread_client(connection: str, **kwargs) Client

Initialize a gspread client, based on an AutoKitteh connection.

API documentation: https://docs.gspread.org/en/latest/ https://github.com/burnash/gspread

Parameters:

connection – AutoKitteh connection name.

Returns:

gspread client.

Raises:
autokitteh.google.youtube_client(connection: str, **kwargs)

Initialize a YouTube Data API client, based on an AutoKitteh connection.

Code samples: - https://github.com/youtube/api-samples/tree/master/python

Parameters:

connection – AutoKitteh connection name.

Returns:

YouTube Data API client.

Raises:

autokitteh.packages module

autokitteh.packages.install(*packages)

Install Python packages using pip.

A package can be either a package requirement specifier (see https://pip.pypa.io/en/stable/reference/requirement-specifiers/) or a tuple of (package specifier, import name) in case the import name differs from the package name (e.g. Package pillow import imported as PIL).

Please refrain from using this function in production code, specify your dependencies in requirements.txt instead.

Examples: >>> install(‘requests’, ‘numpy’) >>> install(‘requests ~= 2.32’, ‘numpy == 2.0.0’) >>> install([‘pillow ~= 10.4’, ‘PIL’])

autokitteh.pydantic module

Helpers for initializing Pydantic AI providers (OpenAI, Anthropic, Gateway) based on AutoKitteh connections.

autokitteh.pydantic.anthropic_pydantic_ai_provider(connection: str, **kwargs) AnthropicProvider

Initialize an Anthropic Pydantic AI provider, based on an AutoKitteh connection.

API reference:

https://ai.pydantic.dev/models/anthropic

Parameters:

connection – AutoKitteh connection name.

Returns:

Anthropic Pydantic AI provider.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

  • anthropic.APIError – Anthropic SDK initialization errors.

autokitteh.pydantic.openai_pydantic_ai_provider(connection: str, **kwargs) OpenAIProvider

Initialize an OpenAI Pydantic AI provider, based on an AutoKitteh connection.

API reference:

https://ai.pydantic.dev/models/openai

Parameters:

connection – AutoKitteh connection name.

Returns:

OpenAI Pydantic AI provider.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

  • OpenAIError – Connection attempt failed, or connection is unauthorized.

autokitteh.pydantic.pydantic_gateway_provider(connection: str, *args, **kwargs) Provider[Any]

Initialize a Pydantic Gateway provider, based on an AutoKitteh connection.

API reference: https://platform.openai.com/docs/api-reference/ https://github.com/openai/openai-python/blob/main/api.md

Parameters:

connection – AutoKitteh connection name.

Returns:

Pydantic Gateway provider.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

autokitteh.aws module

Initialize a Boto3 (AWS SDK) client, based on an AutoKitteh connection.

autokitteh.aws.boto3_client(connection: str, service: str, region: str = '', **kwargs)

Initialize a Boto3 (AWS SDK) client, based on an AutoKitteh connection.

API reference: https://boto3.amazonaws.com/v1/documentation/api/latest/index.html

Code samples: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/examples.html

Parameters:
  • connection – AutoKitteh connection name.

  • service – AWS service name.

  • region – AWS region name.

Returns:

Boto3 client.

Raises:
  • ValueError – AutoKitteh connection or AWS service/region names are invalid.

  • BotoCoreError – Authentication error.

autokitteh.pipedrive module

Initialize an Anthropic client, based on an AutoKitteh connection.

autokitteh.pipedrive.pipedrive_client(connection: str) Client

Initialize a Pipedrive client, based on an AutoKitteh connection.

API reference:

https://pypi.org/project/pipedrive-python-lib/

Parameters:

connection – AutoKitteh connection name.

Returns:

Pipedrive API client.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

autokitteh.openai module

Initialize an OpenAI client, based on an AutoKitteh connection.

autokitteh.openai.openai_client(connection: str) OpenAI

Initialize an OpenAI client, based on an AutoKitteh connection.

API reference: https://platform.openai.com/docs/api-reference/ https://github.com/openai/openai-python/blob/main/api.md

Parameters:

connection – AutoKitteh connection name.

Returns:

OpenAI API client.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

  • OpenAIError – Connection attempt failed, or connection is unauthorized.

autokitteh.outcomes module

autokitteh.outcomes.http_outcome(status_code: int = 200, *, body: Any = None, json: Any = None, headers: dict[str, str] = {}, more: bool = False, event_id: str | None = None) None

Respond to an HTTP request.

Works both in durable and nondurable sessions.

Parameters:
  • status_code – HTTP status code to return. Ignored if not the first response to a request.

  • body – body to return. If it is a dict or a list, it will be serialized as JSON. If it is a string or bytes, it will be returned as-is.

  • json – JSON-serializable value to return as JSON. If specified, the Content-Type header will be set to application/json. Cannot be used together with body.

  • headers – dict of headers to return.

  • more – If True, indicates that more responses will follow for this request.

  • event_id – Optional event ID to associate the outcome with.

autokitteh.outcomes.outcome(v: Any, *, event_id: str | None = None) None

Log an outcome for the current session.

Works both in durable and nondurable sessions.

Parameters:
  • v – The outcome value. Can be any JSON-serializable value.

  • event_id – Optional event ID to associate the outcome with.

autokitteh.kubernetes module

autokitteh.kubernetes.kubernetes_client(connection: str) ModuleType

Initialize a Kubernetes client, based on an AutoKitteh connection.

API reference: https://github.com/kubernetes-client/python https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/

Parameters:

connection – AutoKitteh connection name.

Returns:

Kubernetes API client.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – If the connection config is missing or invalid, or if an unexpected error occurs during client initialization.

autokitteh.anthropic module

Initialize an Anthropic client, based on an AutoKitteh connection.

autokitteh.anthropic.anthropic_client(connection: str) Anthropic

Initialize an Anthropic client, based on an AutoKitteh connection.

API reference:

https://docs.anthropic.com/claude/reference https://github.com/anthropics/anthropic-sdk-python

Parameters:

connection – AutoKitteh connection name.

Returns:

Anthropic API client.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

  • anthropic.APIError – Anthropic SDK initialization errors.

autokitteh.errors module

AutoKitteh SDK errors.

exception autokitteh.errors.AtlassianOAuthError(connection: str)

Bases: AutoKittehError

API calls not supported by OAuth-based Atlassian connections.

exception autokitteh.errors.AuthenticationError(connection: str, reason: str)

Bases: Exception

Authentication failed.

exception autokitteh.errors.AutoKittehError(*args)

Bases: Exception

Generic base class for all errors in the AutoKitteh SDK.

exception autokitteh.errors.ConnectionInitError(connection: str)

Bases: AutoKittehError

A required AutoKitteh connection was not initialized yet.

exception autokitteh.errors.EnvVarError(env_var: str, desc: str)

Bases: AutoKittehError

A required environment variable is missing or invalid.

exception autokitteh.errors.OAuthRefreshError(connection: str, error)

Bases: AutoKittehError

OAuth token refresh failed.

autokitteh.notion module

Initialize Notion client, based on an AutoKitteh connection.

autokitteh.notion.notion_client(connection: str) Client

Initialize a Notion client, based on an AutoKitteh connection.

API reference:

https://developers.notion.com/docs https://github.com/ramnes/notion-sdk-py

Parameters:

connection – AutoKitteh connection name.

Returns:

Notion client object.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

autokitteh.github module

Initialize a GitHub client, based on an AutoKitteh connection.

class autokitteh.github.AppAuth(app_id: int, ak_connection_name: str)

Bases: AppAuth

Generate JWTs without exposing the GitHub app’s private key.

Based on: https://github.com/PyGithub/PyGithub/blob/main/github/Auth.py

create_jwt(expiration: int | None = None) str

Create a signed JWT https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-a-github-app

Return string:

jwt

autokitteh.github.github_client(connection: str, **kwargs) Github

Initialize a GitHub client, based on an AutoKitteh connection.

API reference and examples: https://pygithub.readthedocs.io/

Parameters:

connection – AutoKitteh connection name.

Returns:

PyGithub client.

Raises:
  • ValueError – AutoKitteh connection name or GitHub app IDs are invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

autokitteh.reddit module

Initializes a Reddit client, based on an AutoKitteh connection.

autokitteh.reddit.reddit_client(connection: str) Reddit

Initialize a Reddit client, based on an AutoKitteh connection.

API reference: https://praw.readthedocs.io/en/stable/

Parameters:

connection – AutoKitteh connection name.

Returns:

Reddit API client.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

autokitteh.atlassian module

Initialize an Atlassian client, based on an AutoKitteh connection.

autokitteh.atlassian.confluence_client(connection: str, **kwargs) Confluence

Initialize an Atlassian Confluence client, based on an AutoKitteh connection.

API reference: https://atlassian-python-api.readthedocs.io/confluence.html

Code samples: https://github.com/atlassian-api/atlassian-python-api/tree/master/examples/confluence

Parameters:

connection – AutoKitteh connection name.

Returns:

Atlassian-Python-API Confluence client.

Raises:
autokitteh.atlassian.get_base_url(connection: str) str | None

Get the base URL of an AutoKitteh connection’s Atlassian server.

Parameters:

connection – AutoKitteh connection name.

Returns:

Base URL of the Atlassian connection, or None if the AutoKitteh connection was not initialized yet.

Raises:

ValueError – AutoKitteh connection name is invalid.

autokitteh.atlassian.jira_client(connection: str, **kwargs) Jira

Initialize an Atlassian Jira client, based on an AutoKitteh connection.

API reference: https://atlassian-python-api.readthedocs.io/jira.html

Code samples: https://github.com/atlassian-api/atlassian-python-api/tree/master/examples/jira

Parameters:
  • connection – AutoKitteh connection name.

  • **kwargs – Additional keyword arguments passed to the Jira client. Common options include: - ‘url’: URL of the Jira instance. - ‘username’: Username for Jira authentication. - ‘password’: Password for Jira authentication. - ‘token’: API token for Jira authentication. - ‘verify_ssl’: Boolean to verify SSL certificates. For a full list of accepted arguments, see: https://github.com/atlassian-api/atlassian-python-api/blob/master/atlassian/rest_client.py#L48

Returns:

Atlassian-Python-API Jira client.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

  • EnvVarError – Required environment variable is missing or invalid.

autokitteh.twilio module

Initialize a Twilio client, based on an AutoKitteh connection.

autokitteh.twilio.twilio_client(connection: str) Client

Initialize a Twilio client, based on an AutoKitteh connection.

API reference: https://www.twilio.com/docs/libraries/python

Parameters:

connection – AutoKitteh connection name.

Returns:

Twilio client.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

autokitteh.slack module

Slack client initialization, and other helper functions.

autokitteh.slack.normalize_channel_name(name: str) str

Convert arbitrary text into a valid Slack channel name.

See: https://api.slack.com/methods/conversations.create#naming

Parameters:

name – Desired name for a Slack channel.

Returns:

Valid Slack channel name.

autokitteh.slack.slack_client(connection: str, **kwargs) WebClient

Initialize a Slack client, based on an AutoKitteh connection.

API reference: https://slack.dev/python-slack-sdk/api-docs/slack_sdk/web/client.html

This function doesn’t initialize a Socket Mode client because the AutoKitteh connection already has one to receive incoming events.

Parameters:

connection – AutoKitteh connection name.

Returns:

Slack SDK client.

Raises:
  • ValueError – AutoKitteh connection name is invalid.

  • ConnectionInitError – AutoKitteh connection was not initialized yet.

  • SlackApiError – Connection attempt failed, or connection is unauthorized.

autokitteh.auth0 module

autokitteh.auth0.auth0_client(connection: str, **kwargs) AsyncAuth0

Initialize an Auth0 client, based on an AutoKitteh connection.

API reference: https://auth0-python.readthedocs.io/en/latest/

Parameters:

connection – AutoKitteh connection name.

Returns:

Auth0 SDK client.

Raises:
  • ConnectionInitError – If the connection is not initialized.

  • ValueError – If the connection name is invalid.

Indices and tables