RSFlowHub Python SDK
The official Python library for the RSFlowHub AI API. Add sentiment analysis, translation, AI chat, PII redaction, spam and comment moderation, review and support-ticket AI, knowledge-base search (RAG) and chatbots to Django, FastAPI, Flask, Celery jobs, scripts and notebooks with one API key.
- Never out of date. Methods are not hard-coded. A new RSFlowHub API works the day it ships:
client.ai.new_endpoint_name(...). No SDK upgrade needed. - Sync and async.
RSFlowHubandAsyncRSFlowHubshare one API, built on httpx. - Typed. Every method has typed keyword arguments (with
Literalchoices and limits in the docstring), generated from the RSFlowHub OpenAPI spec. Works with mypy, Pyright and your IDE. - Typed errors.
ValidationError,InsufficientCreditsError,RateLimitErrorand more, each with the API's error code, message and request id. - Retries built in. 429 and temporary 5xx answers are retried with backoff, respecting
Retry-After. Those answers never charge credits.
Python 3.9+. Other languages: Node.js / TypeScript · PHP · Examples
Install
pip install rsflowhub
poetry add rsflowhub · uv add rsflowhub
Get an API key from the RSFlowHub dashboard (free credits included).
Quick start
from rsflowhub import RSFlowHub
client = RSFlowHub() # reads RSFLOWHUB_API_KEY; or RSFlowHub(api_key="rfh_...")
res = client.ai.sentiment_analysis(text="Setup took two minutes and support answered right away.")
print(res.result["sentiment"]) # "positive"
print(res.request_id) # "req_..." quote it when you contact support
Every API answer is the envelope {success, request_id, data, meta}; AI endpoints put their output in data.result. A call returns a read-only rsflowhub.Response:
res.result |
the AI output (data.result), or data when there is none |
res.data, res["key"], dict(res) |
everything under data |
res.get_path("result.aspects.0.name") |
dot-path read with an optional default |
res.request_id, res.meta, res.status_code, res.headers |
envelope and HTTP details |
res.rate_limit |
{"limit", "remaining", "reset"} from the X-RateLimit-* headers |
Async (FastAPI, aiohttp, Django async views)
from fastapi import FastAPI
from rsflowhub import AsyncRSFlowHub
app = FastAPI()
client = AsyncRSFlowHub()
@app.post("/moderate")
async def moderate(comment: str):
res = await client.ai.comment_moderate(comment=comment)
return res.result
async with AsyncRSFlowHub() as client: closes connections for you; in a long-running app create one client and reuse it.
Calling any API
The method name is the endpoint slug in snake_case (camelCase works too):
| API | Call |
|---|---|
POST /ai/sentiment-analysis |
client.ai.sentiment_analysis(text=...) |
POST /ai/translation |
client.ai.translation(text="Hello", target_language="French") |
POST /ai/chat |
client.ai.chat(message="Hi!") |
POST /ai/pii-redaction |
client.ai.pii_redaction(text="Call me on 555-0100") |
POST /ai/ticket-analyze |
client.ai.ticket_analyze(ticket="My order never arrived") |
POST /ai/any-new-api |
client.ai.any_new_api(...) (works without an SDK update) |
All methods with their parameters: docs/ENDPOINTS.md. API docs: rsflowhub.com/docs.
The body can be keyword arguments or one dict: client.ai.chat({"message": "Hi!"}).
Knowledge bases (RAG) and chatbots
Ids in the URL come first:
from pathlib import Path
kb = client.knowledge_bases.create(name="Help center")
kb_id = kb.get_path("knowledge_base.id")
client.knowledge_bases.create_document(kb_id, file=Path("refund-policy.pdf"))
answer = client.knowledge_bases.ask(kb_id, question="Can I get a refund after 30 days?")
reply = client.chatbots.send_message(chatbot_id, message="Where is my order?")
A pathlib.Path, bytes or open binary file turns the request into a file upload.
Any route
usage = client.request("GET", "/account/usage", query={"page": 2})
Errors
import rsflowhub
try:
client.ai.text_summarize(text=article)
except rsflowhub.ValidationError as e:
print(e.errors) # {"text": ["The text field is required."]}
except rsflowhub.InsufficientCreditsError as e:
print(e.required_credits, e.available_credits)
except rsflowhub.RateLimitError as e:
print(e.retry_after) # already retried max_retries times
except rsflowhub.APIError as e:
print(e.status_code, e.code, e.message, e.request_id)
except rsflowhub.APIConnectionError:
print("network problem or timeout")
| Error | When | Error codes |
|---|---|---|
AuthenticationError |
401 | API_KEY_MISSING, INVALID_API_KEY |
InsufficientCreditsError |
402 | INSUFFICIENT_CREDITS |
PermissionDeniedError |
403 | SPENDING_LIMIT_REACHED, USER_INACTIVE |
NotFoundError |
404 | ENDPOINT_NOT_FOUND |
ValidationError |
422 | VALIDATION_ERROR |
RateLimitError |
429 | RATE_LIMIT_EXCEEDED |
InternalServerError |
500 | INTERNAL_SERVER_ERROR |
ServiceUnavailableError |
502 / 503 | PROVIDER_UNAVAILABLE, AI_PROVIDER_ERROR |
APIConnectionError / APITimeoutError |
no answer / too slow |
All of them extend rsflowhub.RSFlowHubError.
Options
client = RSFlowHub(
api_key="rfh_...", # default: RSFLOWHUB_API_KEY
base_url="https://rsflowhub.com/api/v1", # default: RSFLOWHUB_BASE_URL
timeout=60.0, # seconds
max_retries=2, # for 429, 502, 503, 504 and network errors
default_headers={}, # extra headers on every request
http_client=None, # your own httpx.Client (proxies, event hooks, tests)
live_spec=True, # look up unknown non-AI methods in the live OpenAPI spec
)
# per call
client.ai.chat(message="Hi", timeout=10, max_retries=0, extra_headers={"X-Trace": "abc"})
Django, Flask and Celery
Create the client once (module level or app startup) and reuse it; it is thread-safe. See examples/: Django view, Flask, FastAPI, script.
How it stays up to date
RSFlowHub publishes a machine-readable OpenAPI document generated from the API's own routes and validation rules. This SDK uses it in three ways:
- AI endpoints are called by name, so new ones work at once.
- Other new routes (for example a new knowledge-base action) are looked up in the live document the first time you call them.
- Types and docs (
src/rsflowhub/_generated,docs/ENDPOINTS.md) are regenerated every week by a GitHub workflow that opens a pull request when the API changed.
To regenerate by hand: python scripts/generate.py [url-or-file].
Contributing
Issues and pull requests are welcome: pip install -e ".[dev]", then pytest and mypy. Do not edit generated files (src/rsflowhub/_generated, docs/ENDPOINTS.md); change scripts/generate.py instead.
License
MIT. See LICENSE.
Metadata
Release files for rsflowhub 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rsflowhub-1.0.0.tar.gz | 26.9 kB | With provenance | Details for rsflowhub-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rsflowhub-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for rsflowhub-1.0.0-py3-none-any.whl |
Total release size: 54.2 kB
Release files / rsflowhub-1.0.0.tar.gz
| Download URL | rsflowhub-1.0.0.tar.gz |
|---|---|
| Size | 26.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
57c55b97f25a7d25bd0bc7e30fb666a8a587f8ed7c08699154dea25710b6f47c
|
|
BLAKE2b-256 checksum How to use checksums |
cf2ec8a98911b3d531c9b7c53128ed8982e08df9044afb7ffe673dea5968cb03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 18, 2026.
Transparency logRelease files / rsflowhub-1.0.0-py3-none-any.whl
| Download URL | rsflowhub-1.0.0-py3-none-any.whl |
|---|---|
| Size | 27.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f89b9ed775709215918d4d7e6b9d36c01eff8c170fa71718bef69c0e18714f5e
|
|
BLAKE2b-256 checksum How to use checksums |
1e65e514fb0618eeec55522742f6229b37c0d782719b70b6c86335a3899426fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 18, 2026.
Transparency logSecurity for rsflowhub 1.0.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.
Attestation for rsflowhub-1.0.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 Oct 18, 2026.
Transparency logA 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.