retvest

Retvest Deploy / Documentation

Python SDK

Client setup, queries and error handling in Python.

Connect the Python client

Use the versioned SDK package and connection details supplied for your Deploy pilot. Ask for developer access if you do not have them. Examples here describe the client interface; they are not connected to a live public demo.

The package name is retvest-client; the import is retvest_client. Supply your company API URL and a permitted raw Retvest API key through the environment. Do not prefix the key with Bearer.

PythonInterface example
import os
from retvest_client import RetvestClient

client = RetvestClient(
    os.environ["RETVEST_API_URL"],
    api_key=os.environ["RETVEST_API_KEY"],
)

answer = client.query(
    "Summarise the approved sample policy.",
    top_k=5,
)

Keep the result in your application

The query result contains the answer for your application to handle. The example intentionally does not print business content. Use approved sample material while establishing the integration and keep credentials out of code, notebooks and logs.

Limit the question to the intended collection

When the workflow targets a specific approved collection, pass its identifier rather than relying on an ambiguous default. The account must already have access to that material. top_k is a retrieval setting, not an assurance of answer quality.

Python / Collection-scoped queryInterface example
answer = client.query(
    "What does the approved policy say about expenses?",
    collection_id=os.environ["RETVEST_COLLECTION_ID"],
    top_k=5,
)
answer_text = answer["answer"]

Use async when your application needs it

Python / asyncInterface example
import os
from retvest_client import AsyncRetvestClient

client = AsyncRetvestClient(
    os.environ["RETVEST_API_URL"],
    api_key=os.environ["RETVEST_API_KEY"],
)
answer = await client.query("Summarise the approved sample policy.")

The async example belongs inside your application’s async execution context.

Consume a stream as a lifecycle

query_stream() consumes server-sent events. Use the event types supplied by your package version, render source information and text in their proper order, and wait for the success terminal event. A disconnect or protocol error leaves an incomplete answer; preserve that distinction in your interface.

Respect the operation’s authentication

Query automation and administrative Work Run operations do not share the same authentication assumptions. The documented Work Run correction helpers use an authorised session. An API key alone does not grant access to session-only administration.

Plan for errors and retries

The source interface exposes typed errors with status, code and request metadata. Idempotent reads can use the client retry policy; uploads, queries and review transitions are not interchangeable with reads. Use the exact policy supplied with your package version.

Authentication and streaming concepts → / SDK overview →

Your Deploy environment

Discuss the integration

Developer access