Skip to main content

Python SDK for the RaySearch personal API service.

Project description

raysearch-sdk-py

Python SDK for the RaySearch personal API service.

The SDK provides:

  • top-level RaySearch and AsyncRaySearch clients
  • search, fetch, and answer helpers
  • a dedicated research client for async research task workflows

Install

uv add raysdk-py
pip install raysdk-py

Requires Python 3.11+

By default the SDK targets http://localhost:8000.

Authentication uses a bearer token:

  • pass api_key="..." explicitly
  • or set RAYSEARCH_API_KEY

Quick Start

from raysdk_py import RaySearch

client = RaySearch(api_key="your-api-key")

search_response = client.search(
    "latest multimodal model papers",
    user_location="US",
    fetchs={"content": True},
)

answer_response = client.answer(
    "What are the key findings from recent multimodal model papers?",
    content=True,
)

Search

results = client.search(
    "latest AI research papers",
    user_location="US",
    fetchs={"content": True},
)
results = client.search(
    "climate tech news",
    user_location="US",
    mode="deep",
    max_results=10,
    additional_queries=["climate startup funding", "battery storage news"],
    include_domains=["techcrunch.com", "reuters.com"],
    start_published_date="2024-01-01",
    fetchs={
        "content": {"detail": "standard", "max_chars": 5000},
        "abstracts": {"query": "main findings", "max_chars": 300},
        "overview": True,
    },
)
results = client.search(
    "multimodal benchmark papers",
    user_location="US",
    include_text=["benchmark"],
    exclude_text=["advertisement"],
    fetchs={
        "content": {"detail": "concise"},
        "subpages": {"max_subpages": 2, "subpage_keywords": ["method", "results"]},
        "others": {"max_links": 5},
    },
)

Use fetchs to control what extra content is produced for each search result:

  • content
  • abstracts
  • subpages
  • overview
  • others

Fetch

response = client.fetch(
    ["https://docs.python.org/3/", "https://pydantic.dev/"],
    content=True,
)
response = client.fetch(
    "https://arxiv.org/abs/2401.00123",
    crawl_mode="preferred",
    content={"detail": "full", "max_chars": 12000},
    abstracts={"query": "main contribution", "max_chars": 400},
    overview={
        "query": "Summarize the paper contributions",
        "json_schema": {
            "type": "object",
            "properties": {
                "title": {"type": "string"},
                "contributions": {"type": "array", "items": {"type": "string"}},
            },
            "required": ["contributions"],
        },
    },
    others={"max_links": 10, "max_image_links": 5},
)

Fetch responses include:

  • results: successful extracted pages
  • statuses: per-URL success/error status entries

Answer

response = client.answer("What caused the 2008 financial crisis?")
print(response.answer)
response = client.answer(
    "Summarize recent multimodal model trends",
    json_schema={
        "type": "object",
        "properties": {
            "summary": {"type": "string"},
            "key_papers": {"type": "array", "items": {"type": "string"}},
        },
        "required": ["summary", "key_papers"],
    },
    content=True,
)

print(response.answer)
for citation in response.citations:
    print(citation.title, citation.url)

Set content=True to include citation content snippets in the response.

Research

Research uses a task workflow:

  1. create a research task
  2. poll or fetch the task until it finishes
  3. inspect the final output
task = client.research.create(
    themes="Current trends in multimodal AI research",
    search_mode="research",
)

print(task.research_id)
print(task.status)
task = client.research.create(
    themes="State of battery storage startups in 2025",
    search_mode="research-pro",
    json_schema={
        "type": "object",
        "properties": {
            "summary": {"type": "string"},
            "companies": {"type": "array", "items": {"type": "string"}},
            "key_trends": {"type": "array", "items": {"type": "string"}},
        },
        "required": ["summary", "companies", "key_trends"],
    },
)
task = client.research.get("your-research-id")
print(task.status)
if task.output is not None:
    print(task.output.content)
    print(task.output.structured)
task = client.research.poll_until_finished(
    "your-research-id",
    poll_interval=1000,
    timeout_ms=600000,
)

print(task.status)
print(task.output.content if task.output else None)
tasks = client.research.list(limit=10)
print(tasks.has_more, tasks.next_cursor)

for task in tasks.data:
    print(task.research_id, task.status)
for task in client.research.list_all(limit=20):
    print(task.research_id, task.status)
canceled = client.research.cancel("your-research-id")
print(canceled.status)

Research task statuses:

  • pending
  • running
  • completed
  • canceled
  • failed

Research search modes:

  • research-fast
  • research
  • research-pro

Health Check

health = client.healthz()
print(health.status, health.engine_ready)

Async

from raysdk_py import AsyncRaySearch

client = AsyncRaySearch(api_key="your-api-key")

search_response = await client.search(
    "async search example",
    user_location="US",
    fetchs={"content": True},
)

research_task = await client.research.create(
    themes="Recent open-source multimodal models",
    search_mode="research",
)

completed = await client.research.poll_until_finished(research_task.research_id)
print(completed.status)

More

Main entry points:

  • RaySearch
  • AsyncRaySearch

Main operation groups:

  • search(...)
  • fetch(...)
  • answer(...)
  • research.create(...)
  • research.get(...)
  • research.list(...)
  • research.poll_until_finished(...)

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

raysdk_py-0.1.0.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

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

raysdk_py-0.1.0-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file raysdk_py-0.1.0.tar.gz.

File metadata

  • Download URL: raysdk_py-0.1.0.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for raysdk_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 aa60dde6266c807eae86bb7fbc0537ba4f7e081da88a0798d2d62ca77945cba8
MD5 a8091006da7cb4aeb2f46855acea3770
BLAKE2b-256 c81a0608bafda6dab028f6945af7626abe72ba9bb876f5bd6b39156583dd0b1a

See more details on using hashes here.

File details

Details for the file raysdk_py-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: raysdk_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for raysdk_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ebf8807fd67ec024c863560664e855b9291ddd72c40e59d1810573d5b2ac9ad
MD5 d7e5eb664d24839757f0e13d60c51472
BLAKE2b-256 877c785666a98861489757749bfc6ca8c57f1f9d0270f76407096baa3ad09850

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