Skip to main content

Oreag Python SDK

Python 3.10+. Install a published release with pip install oreag-sdk. For a source checkout, run pip install ./sdk/python from the repository root.

import os
from oreag import Oreag, OreagError
with Oreag(os.environ['OREAG_API_KEY'], os.environ['OREAG_PROJECT_ID']) as oreag:
    answer = oreag.query('What is the policy?', top_k=5, conversation_id='session-1')
    for event in oreag.stream_query('Explain the policy'):
        if event['type'] == 'token':
            print(event['text'], end='', flush=True)
    # Submit a rating only after collecting it from the user:
    if answer['query_id'] is not None:
        oreag.feedback(answer['query_id'], 'not_helpful', 'Missing the new policy')
        saved = oreag.get_test_set()
        oreag.add_to_test_set(answer['query_id'], 'Return within 30 days.', saved['revision'])

Use upload_files([('policy.txt', binary_file)]) with an upload-enabled key. Wait for the file.indexed event before querying new content. get_query(id) includes query timings; health() reads knowledge health. start_evaluation(str(uuid.uuid4()), suite) queues a background run; poll get_evaluation(id) or subscribe to completion events. Request/answer/source/conversation fields match the public API.

OreagError exposes status, detail, and retry_after. Requests are never automatically retried; an interrupted request may already have incurred cost. Respect Retry-After and retry only when safe. Close partially consumed streaming generators explicitly (stream.close() or contextlib.closing) to release the connection. Keep API keys on your server. example.py runs with OREAG_API_KEY and OREAG_PROJECT_ID environment variables.

from oreag import verify_webhook
event = verify_webhook(raw_request_bytes, request_headers, signing_secret)
# Persist event['id'] with a UNIQUE constraint and queue work atomically.
# Return 2xx after persistence; duplicate events should be successful no-ops.

Verify the exact raw bytes before parsing JSON. Verification allows five minutes of clock skew. Events can repeat and arrive out of order. Run python -m unittest test_sdk.py from this directory.

Safe retries (0.2.0)

Pass idempotency_key="one-logical-request" to query, upload_files, or start_evaluation. Reuse the same key and content after a lost response. The server retains encrypted completed responses for 24 hours, scoped to the API key and operation. Different content returns 409; pending or uncertain work also returns 409 and is never executed again with that key within the retention window. Inspect the resource before creating a new key for an uncertain operation. Streaming does not support this header. These clients never retry automatically.

See CHANGELOG.md for release changes. Versioned packages are built and checked by the repository SDK release workflow.

License

The SDK retains the Oreag proprietary, viewing-only license in LICENSE. Publication or download does not grant application-use rights; obtain the owner's written permission for use beyond that license.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oreag_sdk-0.2.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

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

oreag_sdk-0.2.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file oreag_sdk-0.2.0.tar.gz.

File metadata

  • Download URL: oreag_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for oreag_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 18d6b122a6ecd13bff7aff77bc2102532a9a192a863929e90d13beb4c373db26
MD5 0ff90a2c8b80539c2a8bd364ba2ad3f1
BLAKE2b-256 6848a3d164f0c3a40340230edb6bd8459a7dcebd5876d68f68014869c7ee97b4

See more details on using hashes here.

File details

Details for the file oreag_sdk-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: oreag_sdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for oreag_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 99869ef9305c85455d799d691b2081e662d0ee6f9f6c7a80e6eb4dcdf4d2d976
MD5 1d58ecea2e89a2a33f9c786072b1f2bf
BLAKE2b-256 baef62820b55735ed8cc14f318d8c96e9a65f3e068f3ee93982692c7a7dc9b5a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

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