Skip to main content

relevan

Python client for the Relevan search API.

  • Typed, generated from Relevan's live OpenAPI 3.1 spec (GET /openapi).
  • Sync and async clients with the same method surface.
  • Retries on rate limits, honoring the server's Retry-After header.
  • Beta endpoints are grouped under client.beta and warn on every call.

Install

pip install relevan

Quickstart

from relevan import Client

client = Client()  # reads RELEVAN_API_KEY from the environment

org = client.organizations.list()[0]
skill_doc = client.skill.get(org.id, "products")  # read once before querying an index

results = client.search.search(org.id, "products", query="wireless headphones")
for hit in results.results:
    print(hit.id, hit.explanation)

# Close the loop: tell Relevan what happened to a result.
client.beta.send_feedback(
    org.id,
    "products",
    action_name="click",
    query_id=results.search_context.query_id,
    object_id=results.results[0].id,
    position=0,
)

An agent can also grade the whole search once per query with a search_judgment, with optional per-result grades from 0 (not useful) to 2 (very useful):

client.beta.send_feedback(
    org.id,
    "products",
    action_name="search_judgment",
    query_id=results.search_context.query_id,
    grade=1,
    results=[{"object_id": results.results[0].id, "grade": 2, "position": 0}],
    description="The user wanted over-ear headphones; most results were earbuds.",
)

Pass source="eval" on feedback from a test suite or benchmark run, so it stays apart from real traffic.

Before you filter a search, client.search.filter_values(org.id, "products") lists the values each filterable field holds. client.usage.get(org.id) shows where the organization stands against its plan's storage cap.

The async client mirrors this exactly:

from relevan import AsyncClient

async with AsyncClient() as client:
    org = (await client.organizations.list())[0]
    results = await client.search.search(org.id, "products", query="wireless headphones")

Authentication

Client() and AsyncClient() read the API key from the RELEVAN_API_KEY environment variable by default — the same variable used elsewhere for this API — or accept it directly: Client(api_key="relevan_..."). The key is never written to disk or logged, and is masked in repr(client).

Rate limits

Relevan enforces per-organization rate limits. On a 429, the client retries automatically using the server's Retry-After value (max_retries=2 by default, configurable via Client(max_retries=...)). A RelevanRateLimitError is raised only if retries are exhausted.

After each client.search.search(...) call, client.search.last_rate_limit holds the org's current RateLimit-* snapshot (.limit, .remaining, .reset_seconds), so callers can self-throttle proactively if they want to.

Beta endpoints

Endpoints under the API's /v1-beta path are exposed under client.beta and documented as beta in their docstrings. Their contract may change without warning — each call emits a RelevanBetaWarning so this is visible at the call site, not just in documentation.

import warnings

warnings.simplefilter("once", category=None)  # or filter RelevanBetaWarning specifically

Regenerating the client

src/relevan/_generated/ is generated from the live OpenAPI spec and is never hand-edited:

uv run scripts/generate_client.py --url https://api.dev.relevan.dev/openapi

See that script's docstring for the spec normalization it applies and why.

Development

uv sync --extra dev
uv run ruff check .
uv run mypy src
uv run pytest

Releasing

Releases go to PyPI from the Publish workflow through trusted publishing, so the repository stores no PyPI token.

  1. Set version in pyproject.toml and add a CHANGELOG.md section for it.
  2. Merge to main.
  3. Tag the merge commit v<version> and push the tag. The workflow fails if the tag and pyproject.toml disagree.

License

Apache-2.0

Metadata

Release files for relevan 0.1.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 relevan 0.1.0
File Size Uploaded Provenance Actions
relevan-0.1.0.tar.gz 57.8 kB With provenance Details for relevan-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for relevan 0.1.0
File Interpreter ABI Platform Actions
relevan-0.1.0-py3-none-any.whl Python 3 none any Details for relevan-0.1.0-py3-none-any.whl

Total release size: 196.3 kB

Release files / relevan-0.1.0.tar.gz

Download URL relevan-0.1.0.tar.gz
Size 57.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ba95408521e2df6eb69ae804f4c9eec652dcb3090336256fc4ca0f8f4a16dc56
BLAKE2b-256 checksum
How to use checksums
1a8fa6d1f14b40fea987909d1b1bc83fc2b2cb5b1267b8b12676ff5411b74652
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 18, 2026.

Transparency log

Release files / relevan-0.1.0-py3-none-any.whl

Download URL relevan-0.1.0-py3-none-any.whl
Size 138.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ce7aba81dd921c60071281de58a4bf1c8cc3f8c1ca262c57e557e89c0058e7d
BLAKE2b-256 checksum
How to use checksums
97fc9b49222dd8435bbe0ea544075b18032c45b44bb592d01a0c8f3bd7322f96
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 18, 2026.

Transparency log

Security for relevan 0.1.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 relevan-0.1.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 18, 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

0.1.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