Skip to main content

SmartSearch AI SDK for Python

Version 4.7.0 targets SmartSearch platform 4.7.0. Python 3.10 or later is required. This source version does not establish PyPI availability or live deployment qualification. Maintainers: see PyPI publishing setup and release steps.

From a checkout of this version:

python -m pip install .

Workplace search, answers and chat

The SDK calls the public API through your Gateway api_url. Workspace configuration, membership, document permissions and agentic licensing still apply.

All routes below are POST /workspace/v1/workspaces/{workspace_id}/....

SDK method Route Server behavior
workplace().search(...) /search Regular retrieval with sources; forces retrieval_only
workplace().query(...) /query Agentic query; defaults to retrieval_only; set Mode.ANSWER for an answer
workplace().chat(...) /chat Conversational answer; forces answer; reuse returned session_id
workplace().stream_query(...) /query Same query modes, with SSE
workplace().stream_chat(...) /chat Conversational answer with SSE

query(...) does not select answer mode automatically. The SDK forwards the request's mode; /search and /chat enforce their modes on the server. Streaming methods set options.stream=true and Accept: text/event-stream; buffered methods request JSON.

import os
from smartsearch_ai import Mode, SmartSearchAi, WorkspaceQueryRequest

with SmartSearchAi(
    api_url=os.environ["SMARTSEARCH_API_URL"],
    admin_url=os.environ["SMARTSEARCH_ADMIN_URL"],
    auth_url=os.environ["SMARTSEARCH_AUTH_URL"],
    realm=os.environ["SMARTSEARCH_REALM"],
    client_id=os.environ["SMARTSEARCH_CLIENT_ID"],
    client_secret=os.environ["SMARTSEARCH_CLIENT_SECRET"],
    read_timeout=120,
) as client:
    workspace_id = os.environ["SMARTSEARCH_WORKSPACE_ID"]
    workplace = client.workplace()

    retrieved = workplace.search(workspace_id, WorkspaceQueryRequest(query="refund policy"))
    print(retrieved.body)

    answered = workplace.query(
        workspace_id, WorkspaceQueryRequest(query="What is the refund policy?", mode=Mode.ANSWER)
    )
    print(answered.body)

    first = workplace.chat(workspace_id, WorkspaceQueryRequest(query="Explain the refund policy."))
    followup = workplace.chat(workspace_id, WorkspaceQueryRequest(
        query="Does that include subscriptions?", session_id=first.body["session_id"]
    ))
    print(followup.body)

    with workplace.stream_query(workspace_id, WorkspaceQueryRequest(
        query="Summarize the policy.", mode=Mode.ANSWER
    )) as stream:
        for event in stream:
            print(event.event, event.payload)
        print(stream.result.body)  # Authoritative terminal response after run.completed.

Use stream_chat(...) with session_id for streaming conversation turns. Close streams with with; the SDK raises SmartSearchError for failed or incomplete streams. Buffered WorkspaceResult.body and streamed result bodies preserve the server's JSON fields.

The equivalent public API answer request uses the same explicit mode:

curl --fail-with-body "$SMARTSEARCH_API_URL/workspace/v1/workspaces/$SMARTSEARCH_WORKSPACE_ID/query" \
  -H "Authorization: Bearer $SMARTSEARCH_ACCESS_TOKEN" \
  -H 'Content-Type: application/json' -H 'Accept: application/json' \
  --data '{"query":"What is the refund policy?","mode":"answer"}'

Optional retrieval settings and caller vectors

Version 4.7.0 adds typed SearchStrategyConfig and QueryEmbedding. Omit the whole strategy block to use agent/Workspace defaults. A supplied block does not guarantee per-field inheritance. Existing requests keep their wire format.

from smartsearch_ai import QueryEmbedding, QueryOptions, SearchStrategyConfig, WorkspaceQueryRequest

request = WorkspaceQueryRequest(
    query="refund policy",
    search_strategy_config=SearchStrategyConfig(
        max_variants=3,
        source_type_weights={"pdf": 1.5},
        query_expansion_enabled=True,
        fanout_compiler_version="workspace_typed_fanout_v2",
    ),
)

# Only for a CALLER_VECTORS Workspace configured for this exact model and vector contract.
caller_vector_request = WorkspaceQueryRequest(
    query="refund policy",
    options=QueryOptions(embedding=QueryEmbedding(
        model_id="your-configured-model", model_revision="your-configured-revision",
        shape=[2], values=[0.6, 0.8],  # Replace with the actual model output and dimensions.
    )),
)

SearchStrategyConfig also supports enabled, freshness_boost_enabled, authority_boost_enabled, coverage_selector_enabled and max_keyword_expansions. Compiler values are workspace_typed_fanout_v1 or workspace_typed_fanout_v2. Source weights require nonblank keys and finite numbers. Effective strategy limits remain server-owned.

Embedding values must be a nonempty, finite, rank-one numeric vector within float32 range. Optional shape must equal [len(values)]. Model identity, revision (including omission), dimensions and normalization must match the Workspace's immutable contract; the server validates that contract. Managed-embedding and lexical-only Workspaces reject caller vectors. Metric, normalization and target field cannot be overridden. Unknown fields, identity/security overrides, internal query vectors and server-owned guardrails are not exposed by these models.

These additions cover the public query request fields above, not every platform management API. Offline wire-contract tests do not establish live authorization, model readiness or deployment compatibility; qualify those against your configured Gateway and Workspace before release use.

Registering users

users().submit_job(...) registers users through an integration that an administrator set up in SmartSearch (this SDK cannot create one). Users are created in SmartSearch's sign-in realm either way:

  • Invite (KEYCLOAK_INVITE): each user gets an email to set a SmartSearch password. Send EnsureItem without external_identity.
  • Federated (KEYCLOAK_FEDERATED): each user is linked to their existing account at your identity provider. Every EnsureItem must carry external_identity=ExternalIdentity(subject=..., username=...).

Named codes (SmartSearchError.code, and the code of a failed job item): INTEGRATION_NOT_FOUND, EXTERNAL_IDENTITY_REQUIRED, EXTERNAL_IDENTITY_NOT_SUPPORTED, importable from smartsearch_ai.

Metadata

Release files for smartsearch-ai 4.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for smartsearch-ai 4.7.0
File Size Uploaded Provenance Actions
smartsearch_ai-4.7.0.tar.gz 33.1 kB With provenance Details for smartsearch_ai-4.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for smartsearch-ai 4.7.0
File Interpreter ABI Platform Actions
smartsearch_ai-4.7.0-py3-none-any.whl Python 3 none any Details for smartsearch_ai-4.7.0-py3-none-any.whl

Total release size: 72.5 kB

Release files / smartsearch_ai-4.7.0.tar.gz

Download URL smartsearch_ai-4.7.0.tar.gz
Size 33.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e0fd518be1c84a2f4ba8c1176f0b35e3f5bc9c64a1150ebd29c549ef271395da
BLAKE2b-256 checksum
How to use checksums
bdf6d17941b69b187acb820dbf3b9af02e2303c3ede69379af7cf40281aa88a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / smartsearch_ai-4.7.0-py3-none-any.whl

Download URL smartsearch_ai-4.7.0-py3-none-any.whl
Size 39.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
260afa7e6ec1aa6557509df1d67b7fd34f454321637f4ccba4d7b67a1dfadd7a
BLAKE2b-256 checksum
How to use checksums
7c92ca6f6dfd21e774ac2cacc00418ba1eac3fa90128de1959be33bb863c90ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for smartsearch-ai 4.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for smartsearch_ai-4.7.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

4.7.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page