Skip to main content
sitegpt is the official SiteGPT client for Python. It calls API v2. It uses only the Python standard library and needs Python 3.9 or later.
  • Handles the envelope. The API answers with { ok, data, meta }. The SDK returns data as plain dicts and lists. It raises a SiteGPTError when ok is false.
  • Reaches every endpoint. Convenience methods cover chatbots, content, conversations, leads, messages, and onboarding. Every other API v2 operation works through request().

Install

Quickstart

API access needs the Growth plan or above. See Plans and limits. Create an API token on the Agents page. See Authentication. Then:

Agent onboarding without a token

The agent-first onboarding start endpoint needs no token. The response includes a temporary token for the new chatbot:
health() also works without a token. Every other call returns 401 until you set api_token.

Error handling

Every failed call raises a SiteGPTError with the fields of the API error:
See API conventions for error codes.

Convenience methods

conversations.take_over needs version 0.3.0 or later. It takes over a conversation the same way as the dashboard. See Conversation state conflicts. The client also has sitegpt.me() and sitegpt.health(). Pass body fields and query filters as keyword arguments. Use the API’s own field names, in camelCase, as in the OpenAPI document:
One method is different. chatbots.analytics takes start_day and end_day, as YYYY-MM-DD dates:

Deletes need confirmation

The API needs confirm=true on delete operations. The SDK sends it only when you pass confirm=True. These methods need it: chatbots.delete, knowledge.delete_document, knowledge.delete_documents, knowledge.revoke_source, conversations.delete, and leads.delete. Without it, the SDK raises a CONFIRMATION_REQUIRED error and sends no request.

Other endpoints: request()

request_with_meta() also returns the envelope meta, including meta["nextCursor"] for the next page:

Timeouts and base URL

  • timeout is the time limit for each request, in seconds. The default is 30.
  • base_url is https://sitegpt.ai by default. Change it only if SiteGPT gives you a different API address.