Skip to main content

Python Client SDK Generated by Speakeasy.

Project description

pipeshub-sdk

pipeshub-sdk is the official python client library for integrating Pipeshub into your product and internal tools

Summary

PipesHub API: Unified API documentation for PipesHub services.

PipesHub is an enterprise-grade platform providing:

  • User authentication and management
  • Document storage and version control
  • Knowledge base management
  • Enterprise search and conversational AI
  • Third-party integrations via connectors
  • System configuration management
  • Crawling job scheduling
  • Email services

Authentication

Most endpoints require JWT Bearer token authentication. Some internal endpoints use scoped tokens for service-to-service communication.

Base URLs

All endpoints use the /api/v1 prefix unless otherwise noted.

Table of Contents

SDK Installation

[!NOTE] Python version upgrade policy

Once a Python version reaches its official end of life date, a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated.

The SDK can be installed with uv, pip, or poetry package managers.

uv

uv is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.

uv add pipeshub-sdk

PIP

PIP is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.

pip install pipeshub-sdk

Poetry

Poetry is a modern tool that simplifies dependency management and package publishing by using a single pyproject.toml file to handle project metadata and dependencies.

poetry add pipeshub-sdk

Shell and script usage with uv

You can use this SDK in a Python shell with uv and the uvx command that comes with it like so:

uvx --from pipeshub-sdk python

It's also possible to write a standalone Python script without needing to set up a whole project like so:

#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.10"
# dependencies = [
#     "pipeshub-sdk",
# ]
# ///

from pipeshub_sdk import Pipeshub

sdk = Pipeshub(
  # SDK arguments
)

# Rest of script here...

Once that is saved to a file, you can run it with uv run script.py where script.py can be replaced with the actual file name.

IDE Support

PyCharm

Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.

SDK Example Usage

Example

# Synchronous Example
from pipeshub_sdk import Pipeshub


with Pipeshub() as pipeshub:

    res = pipeshub.user_account.init_auth(email="user@example.com")

    # Handle response
    print(res)

The same SDK client can also be used to make asynchronous requests by importing asyncio.

# Asynchronous Example
import asyncio
from pipeshub_sdk import Pipeshub

async def main():

    async with Pipeshub() as pipeshub:

        res = await pipeshub.user_account.init_auth_async(email="user@example.com")

        # Handle response
        print(res)

asyncio.run(main())

Authentication

Per-Client Security Schemes

This SDK supports the following security schemes globally:

Name Type Scheme Environment Variable
bearer_auth http HTTP Bearer PIPESHUB_BEARER_AUTH
oauth2 oauth2 OAuth2 token PIPESHUB_OAUTH2

You can set the security parameters through the security optional parameter when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:

import os
from pipeshub_sdk import Pipeshub, models


with Pipeshub(
    security=models.Security(
        bearer_auth=os.getenv("PIPESHUB_BEARER_AUTH", ""),
    ),
) as pipeshub:

    res = pipeshub.user_account.init_auth(email="user@example.com")

    # Handle response
    print(res)

Per-Operation Security Schemes

Some operations in this SDK require the security scheme to be specified at the request level. For example:

import os
from pipeshub_sdk import Pipeshub, models


with Pipeshub() as pipeshub:

    res = pipeshub.user_account.reset_password_with_token(security=models.ResetPasswordWithTokenSecurity(
        scoped_token=os.getenv("PIPESHUB_SCOPED_TOKEN", ""),
    ), password="H9GEHoL829GXj06")

    # Handle response
    print(res)

Available Resources and Operations

Available methods

AgentConversations

AgentTemplates

Agents

AIModelsProviders

AuthenticationConfiguration

ConfigurationManager

Connector

ConnectorConfiguration

ConnectorControl

ConnectorFilters

ConnectorInstances

ConnectorOAuth

ConnectorRegistry

Conversations

CrawlingJobs

DocumentManagement

Folders

KnowledgeBases

MetricsCollection

OAuth

OAuthApps

OAuthConfiguration

OAuthProvider

OpenIDConnect

OrganizationAuthConfig

Organizations

Permissions

PlatformSettings

PublicURLs

Records

Saml

SemanticSearch

SMTPConfiguration

StorageConfiguration

Teams

ToolsetConfiguration

ToolsetInstances

ToolsetOAuth

ToolsetRegistry

Upload

UserAccount

UserGroups

Users

Server-sent event streaming

Server-sent events are used to stream content from certain operations. These operations will expose the stream as Generator that can be consumed using a simple for loop. The loop will terminate when the server no longer has any events to send and closes the underlying connection.

The stream is also a Context Manager and can be used with the with statement and will close the underlying connection when the context is exited.

import os
from pipeshub_sdk import Pipeshub, models


with Pipeshub(
    security=models.Security(
        bearer_auth=os.getenv("PIPESHUB_BEARER_AUTH", ""),
    ),
) as pipeshub:

    res = pipeshub.conversations.stream_chat(query="What are the key findings from our Q4 financial report?", record_ids=[
        "507f1f77bcf86cd799439011",
        "507f1f77bcf86cd799439012",
    ], model_key="gpt-4-turbo", model_name="GPT-4 Turbo", chat_mode="balanced")

    with res as event_stream:
        for event in event_stream:
            # handle event
            print(event, flush=True)

File uploads

Certain SDK methods accept file objects as part of a request body or multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.

[!TIP]

For endpoints that handle file uploads bytes arrays can also be used. However, using streams is recommended for large files.

import os
from pipeshub_sdk import Pipeshub, models


with Pipeshub(
    security=models.Security(
        bearer_auth=os.getenv("PIPESHUB_BEARER_AUTH", ""),
    ),
) as pipeshub:

    res = pipeshub.users.upload_user_display_picture(file={
        "file_name": "example.file",
        "content": open("example.file", "rb"),
    })

    # Handle response
    print(res)

Retries

Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.

To change the default retry strategy for a single API call, simply provide a RetryConfig object to the call:

from pipeshub_sdk import Pipeshub
from pipeshub_sdk.utils import BackoffStrategy, RetryConfig


with Pipeshub() as pipeshub:

    res = pipeshub.user_account.init_auth(email="user@example.com",
        RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))

    # Handle response
    print(res)

If you'd like to override the default retry strategy for all operations that support retries, you can use the retry_config optional parameter when initializing the SDK:

from pipeshub_sdk import Pipeshub
from pipeshub_sdk.utils import BackoffStrategy, RetryConfig


with Pipeshub(
    retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
) as pipeshub:

    res = pipeshub.user_account.init_auth(email="user@example.com")

    # Handle response
    print(res)

Error Handling

PipeshubError is the base class for all HTTP error responses. It has the following properties:

Property Type Description
err.message str Error message
err.status_code int HTTP response status code eg 404
err.headers httpx.Headers HTTP response headers
err.body str HTTP body. Can be empty string if no body is returned.
err.raw_response httpx.Response Raw HTTP response
err.data Optional. Some errors may contain structured data. See Error Classes.

Example

from pipeshub_sdk import Pipeshub, errors


with Pipeshub() as pipeshub:
    res = None
    try:

        res = pipeshub.user_account.init_auth(email="user@example.com")

        # Handle response
        print(res)


    except errors.PipeshubError as e:
        # The base class for HTTP error responses
        print(e.message)
        print(e.status_code)
        print(e.body)
        print(e.headers)
        print(e.raw_response)

        # Depending on the method different errors may be thrown
        if isinstance(e, errors.AuthError):
            print(e.data.error)  # Optional[str]
            print(e.data.message)  # Optional[str]
            print(e.data.code)  # Optional[str]
            print(e.data.status_code)  # Optional[int]

Error Classes

Primary error:

Less common errors (10)

Network errors:

Inherit from PipeshubError:

  • AuthError: Authentication error response with details for debugging and user feedback.

    Common Error Codes:
    • INVALID_CREDENTIALS - Wrong password or OTP
    • ACCOUNT_BLOCKED - Account locked after 5 failed attempts
    • SESSION_EXPIRED - Session token has expired
    • OTP_EXPIRED - OTP code has expired (10 min validity)
    • USER_NOT_FOUND - Email not registered
    • INVALID_TOKEN - JWT token is invalid or malformed
    • METHOD_NOT_ALLOWED - Auth method not enabled for org
    . Applicable to 7 of 291 methods.*
  • OAuthErrorResponse: OAuth 2.0 Error Response (RFC 6749 Section 5.2). Standard error format for OAuth endpoints. Applicable to 5 of 291 methods.*
  • ResetPasswordBadRequestError: Invalid current password or weak new password. Status code 400. Applicable to 1 of 291 methods.*
  • SamlSignInCallbackBadRequestError: Invalid SAML response. Status code 400. Applicable to 1 of 291 methods.*
  • UnauthorizedError: SAML authentication failed. Status code 401. Applicable to 1 of 291 methods.*
  • ResponseValidationError: Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the cause attribute.

* Check the method documentation to see if the error is applicable.

Server Selection

Server Variables

The default server https://{instance_url}/api/v1 contains variables and is set to https://https://app.pipeshub.com/api/v1 by default. To override default values, the following parameters are available when initializing the SDK client instance:

Variable Parameter Default Description
instance_url instance_url: str "https://app.pipeshub.com" Base server URL (without /api/v1)

Example

from pipeshub_sdk import Pipeshub


with Pipeshub(
    server_idx=0,
    instance_url="https://app.pipeshub.com",
) as pipeshub:

    res = pipeshub.user_account.init_auth(email="user@example.com")

    # Handle response
    print(res)

Override Server URL Per-Client

The default server can be overridden globally by passing a URL to the server_url: str optional parameter when initializing the SDK client instance. For example:

from pipeshub_sdk import Pipeshub


with Pipeshub(
    server_url="https://https://app.pipeshub.com/api/v1",
) as pipeshub:

    res = pipeshub.user_account.init_auth(email="user@example.com")

    # Handle response
    print(res)

Override Server URL Per-Operation

The server URL can also be overridden on a per-operation basis, provided a server list was specified for the operation. For example:

from pipeshub_sdk import Pipeshub


with Pipeshub() as pipeshub:

    res = pipeshub.open_id_connect.openid_configuration(server_url="")

    # Handle response
    print(res)

Custom HTTP Client

The Python SDK makes API calls using the httpx HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance. Depending on whether you are using the sync or async version of the SDK, you can pass an instance of HttpClient or AsyncHttpClient respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls. This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of httpx.Client or httpx.AsyncClient directly.

For example, you could specify a header for every request that this sdk makes as follows:

from pipeshub_sdk import Pipeshub
import httpx

http_client = httpx.Client(headers={"x-custom-header": "someValue"})
s = Pipeshub(client=http_client)

or you could wrap the client with your own custom logic:

from pipeshub_sdk import Pipeshub
from pipeshub_sdk.httpclient import AsyncHttpClient
import httpx

class CustomClient(AsyncHttpClient):
    client: AsyncHttpClient

    def __init__(self, client: AsyncHttpClient):
        self.client = client

    async def send(
        self,
        request: httpx.Request,
        *,
        stream: bool = False,
        auth: Union[
            httpx._types.AuthTypes, httpx._client.UseClientDefault, None
        ] = httpx.USE_CLIENT_DEFAULT,
        follow_redirects: Union[
            bool, httpx._client.UseClientDefault
        ] = httpx.USE_CLIENT_DEFAULT,
    ) -> httpx.Response:
        request.headers["Client-Level-Header"] = "added by client"

        return await self.client.send(
            request, stream=stream, auth=auth, follow_redirects=follow_redirects
        )

    def build_request(
        self,
        method: str,
        url: httpx._types.URLTypes,
        *,
        content: Optional[httpx._types.RequestContent] = None,
        data: Optional[httpx._types.RequestData] = None,
        files: Optional[httpx._types.RequestFiles] = None,
        json: Optional[Any] = None,
        params: Optional[httpx._types.QueryParamTypes] = None,
        headers: Optional[httpx._types.HeaderTypes] = None,
        cookies: Optional[httpx._types.CookieTypes] = None,
        timeout: Union[
            httpx._types.TimeoutTypes, httpx._client.UseClientDefault
        ] = httpx.USE_CLIENT_DEFAULT,
        extensions: Optional[httpx._types.RequestExtensions] = None,
    ) -> httpx.Request:
        return self.client.build_request(
            method,
            url,
            content=content,
            data=data,
            files=files,
            json=json,
            params=params,
            headers=headers,
            cookies=cookies,
            timeout=timeout,
            extensions=extensions,
        )

s = Pipeshub(async_client=CustomClient(httpx.AsyncClient()))

Resource Management

The Pipeshub class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a context manager and reuse it across the application.

from pipeshub_sdk import Pipeshub
def main():

    with Pipeshub() as pipeshub:
        # Rest of application here...


# Or when using async:
async def amain():

    async with Pipeshub() as pipeshub:
        # Rest of application here...

Debugging

You can setup your SDK to emit debug logs for SDK requests and responses.

You can pass your own logger class directly into your SDK.

from pipeshub_sdk import Pipeshub
import logging

logging.basicConfig(level=logging.DEBUG)
s = Pipeshub(debug_logger=logging.getLogger("pipeshub_sdk"))

You can also enable a default debug logger by setting an environment variable PIPESHUB_DEBUG to true.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pipeshub_sdk-1.0.0.tar.gz (299.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pipeshub_sdk-1.0.0-py3-none-any.whl (570.3 kB view details)

Uploaded Python 3

File details

Details for the file pipeshub_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: pipeshub_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 299.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pipeshub_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 259a36c94ff3168a63d8ebb5f42d7ef53497008e45cd73bef5894ff41c58c40b
MD5 37eb32514ba6a86e0d44c760d0156a84
BLAKE2b-256 af1d8c7da04604f950928ff516e2b22ff7dc514c2d7da4ded084db48423f8872

See more details on using hashes here.

File details

Details for the file pipeshub_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pipeshub_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 570.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pipeshub_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c576d53cf19ac6917a23144840c795fca5b7597b4c67e7abb04e056d7a8c0c15
MD5 8fb317078b4b10be0d792d785b9bcbe5
BLAKE2b-256 4c2f5202171c4d4b834160020beea19d669fa54b62c59def257dd2748fef233b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page