This release is a pre-release and may not be stable for production use.
pip install orq-ai-sdk==4.18.0rc44 Copy PIP instructions
Developer-friendly & type-safe Python SDK specifically catered to leverage orq-ai-sdk API.
For more information about the API: orq.ai Documentation
The SDK can be installed with uv, pip, or poetry package managers.
uv is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.
uv add orq-ai-sdk PIP PIP is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
pip install orq-ai-sdk Poetry Poetry is a modern tool that simplifies dependency management and package publishing by using a single pyproject.toml file to handle project metadata and dependencies.
poetry add orq-ai-sdk Shell and script usage with uv You can use this SDK in a Python shell with uv and the uvx command that comes with it like so:
uvx --from orq-ai-sdk python It's also possible to write a standalone Python script without needing to set up a whole project like so:
#!/usr/bin/env -S uv run --script # /// script # requires-python = ">=3.10" # dependencies = [ # "orq-ai-sdk", # ] # /// from orq_ai_sdk import Orq sdk = Orq( # SDK arguments ) # Rest of script here... Once that is saved to a file, you can run it with uv run script.py where script.py can be replaced with the actual file name.
Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.
# Synchronous Example from orq_ai_sdk import Orq import os with Orq( api_key=os.getenv("ORQ_API_KEY"), ) as orq: res = orq.deployments.invoke(key=" ", stream=False, identity={ "id": "contact_01ARZ3NDEKTSV4RRFFQ69G5FAV", "display_name": "Jane Doe", "email": "jane.doe@example.com", "metadata": [ { "department": "Engineering", "role": "Senior Developer", }, ], "logo_url": "https://example.com/avatars/jane-doe.jpg", "tags": [ "hr", "engineering", ], }, documents=[ { "text": "The refund policy allows customers to return items within 30 days of purchase for a full refund.", "metadata": { "file_name": "refund_policy.pdf", "file_type": "application/pdf", "page_number": 1.0, }, }, { "text": "Premium members receive free shipping on all orders over $50.", "metadata": { "file_name": "membership_benefits.md", "file_type": "text/markdown", }, }, ]) assert res is not None # Handle response print(res) The same SDK client can also be used to make asynchronous requests by importing asyncio.
# Asynchronous Example import asyncio from orq_ai_sdk import Orq import os async def main(): async with Orq( api_key=os.getenv("ORQ_API_KEY"), ) as orq: res = await orq.deployments.invoke_async(key=" ", stream=False, identity={ "id": "contact_01ARZ3NDEKTSV4RRFFQ69G5FAV", "display_name": "Jane Doe", "email": "jane.doe@example.com", "metadata": [ { "department": "Engineering", "role": "Senior Developer", }, ], "logo_url": "https://example.com/avatars/jane-doe.jpg", "tags": [ "hr", "engineering", ], }, documents=[ { "text": "The refund policy allows customers to return items within 30 days of purchase for a full refund.", "metadata": { "file_name": "refund_policy.pdf", "file_type": "application/pdf", "page_number": 1.0, }, }, { "text": "Premium members receive free shipping on all orders over $50.", "metadata": { "file_name": "membership_benefits.md", "file_type": "text/markdown", }, }, ]) assert res is not None # Handle response print(res) asyncio.run(main()) Authentication Per-Client Security Schemes This SDK supports the following security scheme globally:
To authenticate with the API the api_key parameter must be set when initializing the SDK client instance. For example:
from orq_ai_sdk import Orq import os with Orq( api_key=os.getenv("ORQ_API_KEY"), ) as orq: res = orq.deployments.invoke(key=" ", stream=False, identity={ "id": "contact_01ARZ3NDEKTSV4RRFFQ69G5FAV", "display_name": "Jane Doe", "email": "jane.doe@example.com", "metadata": [ { "department": "Engineering", "role": "Senior Developer", }, ], "logo_url": "https://example.com/avatars/jane-doe.jpg", "tags": [ "hr", "engineering", ], }, documents=[ { "text": "The refund policy allows customers to return items within 30 days of purchase for a full refund.", "metadata": { "file_name": "refund_policy.pdf", "file_type": "application/pdf", "page_number": 1.0, }, }, { "text": "Premium members receive free shipping on all orders over $50.", "metadata": { "file_name": "membership_benefits.md", "file_type": "text/markdown", }, }, ]) assert res is not None # Handle response print(res) Available Resources and Operations Available methods Agents create - Create agent list - List agents delete - Delete agent retrieve - Retrieve agent update - Update agent invoke - Execute an agent task ⚠️ Deprecated run - Run an agent with configuration ⚠️ Deprecated stream_run - Run agent with streaming response ⚠️ Deprecated stream - Stream agent execution in real-time ⚠️ Deprecated Agents.External list - List external agents create - Create external agent retrieve - Retrieve external agent delete - Delete external agent update - Update external agent refresh_card - Refresh external agent card test_connection - Test external agent connection Agents.Responses create - Create response ⚠️ Deprecated get - Get response ⚠️ Deprecated Alerts list - List alerts create - Create an alert get - Retrieve an alert delete - Delete an alert update - Update an alert list_triggers - List alert triggers list_trigger_events - List alert trigger events AnnotationQueues list - List annotation queues create - Create an annotation queue retrieve - Retrieve an annotation queue delete - Delete an annotation queue update - Update an annotation queue clear - Clear an annotation queue list_items - Query items from an annotation queue add_items - Add items to an annotation queue remove_items - Remove items from an annotation queue retrieve_item - Retrieve an annotation queue item Annotations create - Annotate a span delete - Remove an annotation from a span ApiKeys list - List API keys create - Create a new API key list_capabilities - List capability catalog delete - Delete an API key get - Retrieve an API key update - Update an API key AuditLogDestinations list - List audit log destinations create - Create an audit log destination get - Retrieve an audit log destination delete - Delete an audit log destination update - Update an audit log destination list_deliveries - List deliveries replay - Replay audit events rotate_secret - Rotate the signing secret test - Send a test event Budgets list - List budgets create - Create a new budget get - Retrieve a budget delete - Delete a budget update - Update a budget reset_consumption - Reset budget consumption Chunking parse - Parse text Datasets list - List datasets create - Create a dataset retrieve - Retrieve a dataset delete - Delete a dataset update - Update a dataset clear - Delete all datapoints list_datapoints - List datapoints create_datapoint - Create datapoints delete_datapoints - Delete specific datapoints create_datapoints - Create multiple datapoints retrieve_datapoint - Retrieve a datapoint delete_datapoint - Delete a datapoint update_datapoint - Update a datapoint Deployments invoke - Invoke stream - Stream list - List all deployments list_versions - List deployment versions get_config - Get config Environments list - List environments create - Create an environment get - Retrieve an environment delete - Delete an environment update - Update an environment Evals all - Get all Evaluators create - Create an Evaluator get - Retrieve an Evaluator delete - Delete an Evaluator update - Update an Evaluator list_versions - List evaluator versions get_version - Get evaluator version invoke - Invoke a Custom Evaluator Experiments list - List experiments create - Create an experiment get - Get an experiment delete - Delete an experiment update - Update an experiment list_runs - List runs create_run - Create a run get_run - Get a run delete_run - Delete a run update_run - Update a run cancel_run - Cancel a run update_run_column_layout - Update column layout list_evals - List eval columns create_eval - Add an eval column delete_eval - Remove an eval column patch_eval_cell - Correct an eval cell execute_run - Execute a run get_run_metrics - Get run metrics query_run - Query run cells list_reviews - List human review columns create_review - Add a human review column delete_review - Remove a human review column update_review - Update review column metadata patch_review_cell - Set a human review cell delete_rows - Delete rows update_run_cell - Update a cell duplicate_row - Duplicate a row list_tasks - List task columns create_task - Add a task column delete_task - Delete a task column update_task - Update a task column patch_task_cell - Ingest a task cell export_run - Export a run Feedback create - Submit feedback remove - Remove feedback submit - Submit feedback Files list - List all files create - Upload a file get_content - Download file content get - Retrieve a file delete - Delete a file update - Update a file FileSystems list - List file systems create - Create file system retrieve - Retrieve file system delete - Delete file system update - Update file system list_files - List files delete_file - Delete file move_file - Move file stat_file - Stat file create_folder - Create folder GuardrailRules list - List guardrail rules create - Create a guardrail rule list_used_guardrails - List guardrails used by guardrail rules retrieve - Retrieve a guardrail rule delete - Delete a guardrail rule update - Update a guardrail rule Hub search - Search hub items get - Get a hub item Identities list - List identities create - Create an identity retrieve - Retrieve an identity delete - Delete an identity update - Update an identity Knowledge list - List all knowledge bases create - Create a knowledge base retrieve - Retrieve a knowledge base delete - Delete a knowledge base update - Update a knowledge base list_datasources - List all datasources create_datasource - Create a new datasource preview_chunks - Preview datasource chunks retrieve_datasource - Retrieve a datasource delete_datasource - Delete a datasource update_datasource - Update a datasource list_chunks - List all chunks for a datasource create_chunks - Create chunks for a datasource delete_chunks - Delete multiple chunks get_chunks_count - Get chunks total count list_chunks_paginated - List chunks with offset-based pagination retrieve_chunk - Retrieve a chunk delete_chunk - Delete a chunk update_chunk - Update a chunk toggle_chunk - Set a chunk's enabled status retrieve_processing_status - Retrieve datasource processing status search - Search knowledge base retrieve_file_url - Retrieve a file upload URL Logs aggregate - Aggregate logs list_facets - List log facets list_facet_values - List facet values list_fields - List log fields find_patterns - Find log patterns query - Query logs with OQL search - Search logs get - Get a single log context - Get surrounding log context list_trace_logs - List logs for a trace ManagementKeys list - List management keys create - Create a new management key list_capabilities - List management capability catalog get - Retrieve a management key delete - Delete a management key update - Update a management key McpGateways list - List MCP gateways create - Create an MCP gateway list_tools - List exposed tools for a gateway retrieve - Retrieve an MCP gateway delete - Delete an MCP gateway update - Update an MCP gateway McpServers list - List MCP servers create - Create an MCP server retrieve - Retrieve an MCP server delete - Delete an MCP server update - Update an MCP server test_tool - Test an MCP server tool sync - Sync an MCP server MemoryStores list - List memory stores create - Create memory store retrieve - Retrieve memory store delete - Delete memory store update - Update memory store list_memories - List all memories create_memory - Create a new memory retrieve_memory - Retrieve a specific memory delete_memory - Delete a specific memory update_memory - Update a specific memory list_documents - List all documents for a memory create_document - Create a new memory document retrieve_document - Retrieve a specific memory document delete_document - Delete a specific memory document update_document - Update a specific memory document ModelCatalog list - List the model catalog list_offerings - List model catalog offerings get - Retrieve a model catalog entry ModelFusions list - List Model Fusions create - Create a Model Fusion get - Retrieve a Model Fusion update - Replace a Model Fusion configuration delete - Delete a Model Fusion set_enabled - Enable or disable a Model Fusion Models create - Create custom model create_aws_bedrock - Create AWS Bedrock custom model validate_aws_bedrock - Validate AWS Bedrock inference profile update_aws_bedrock - Update AWS Bedrock custom model azure_foundry_deployments - List Azure Foundry deployments under a resource import_litellm - Import models from LiteLLM list_litellm - List models from configured LiteLLM instance create_openai_like - Create OpenAI-compatible custom model update_openai_like - Update OpenAI-compatible custom model validate - Validate model endpoint create_vertex - Create Vertex AI custom model delete - Delete custom model update - Update custom model enable - Enable model for workspace disable - Disable model for workspace list - List models Monitors list - List monitors create - Create a monitor list_presets - List monitor presets get - Retrieve a monitor delete - Delete a monitor update - Update a monitor Notifiers list - List notifiers create - Create a notifier get - Retrieve a notifier delete - Delete a notifier update - Update a notifier Pii capabilities - Get PII capabilities detect - Detect PII redact - Redact PII restore - Restore redacted text Policies list - List policies create - Create policy delete - Delete policy retrieve - Get policy update - Update policy Projects list - List all projects create - Create a new project get - Retrieve a project delete - Delete a project update - Update a project Prompts list - List all prompts create - Create a prompt retrieve - Retrieve a prompt update - Update a prompt delete - Delete a prompt list_versions - List all prompt versions get_version - Retrieve a prompt version Reporting query - Query reporting metrics Responses compact - Compact response create - Create response get - Retrieve response Router ocr - Extracts text content while maintaining document structure and hierarchy Router.Audio.Speech create - Create speech Router.Audio.Transcriptions create - Create transcription Router.Audio.Translations create - Create translation Router.Chat.Completions create - Create chat completion Router.Classify create - Classify ⚠️ Deprecated Router.Completions create - Create completion Router.Decisions create - Decisions Router.Embeddings create - Create embeddings Router.Images.Edits create - Create image edit Router.Images.Generations create - Create image Router.Images.Variations create - Create image variation Router.Moderations create - Create moderation Router.Rerank create - Create rerank RoutingRules list - List routing rules create - Create a routing rule list_used_models - List models used by routing rules retrieve - Retrieve a routing rule delete - Delete a routing rule update - Update a routing rule Schedules list - List schedules create - Create schedule delete - Delete schedule retrieve - Retrieve schedule update - Update schedule trigger - Trigger schedule execution Sessions create - Create trace thread get_count - Get thread count list - List trace threads list_tags - List thread tags get - Get trace thread delete - Delete trace thread update - Update trace thread Skills list - List all skills create - Create a new skill get - Retrieve a skill delete - Delete a skill update - Update a skill SmartRouters list - List Smart Routers create - Create a Smart Router get - Retrieve a Smart Router delete - Delete a Smart Router update - Update a Smart Router Telemetry list_capabilities - List telemetry capabilities list_facet_values - List telemetry facet values query - Query telemetry Tools list - List tools create - Create tool update - Update tool delete - Delete tool retrieve - Retrieve tool list_versions - List tool versions get_version - Get tool version Traces aggregate - Aggregate traces list_facets - List trace facets list_facet_values - List trace facet values list_fields - List trace fields list_filters - List trace filters query - Query traces with OQL search - Search traces get - Get trace get_conversation - Get trace conversation list_spans - List trace spans get_span - Get trace span Users list - List workspace users get - Retrieve a workspace user delete - Delete a workspace user update - Update a workspace user create - Create or add workspace users Views list - List visible saved views create - Create a saved view get - Retrieve a saved view delete - Delete a saved view update - Update a saved view Webhooks list - List webhooks create - Create a webhook count - Count webhooks query - Query webhooks ⚠️ Deprecated generate_secret - Generate a webhook secret get - Retrieve a webhook delete - Delete a webhook update - Update a webhook Websearch search - Search the web with a selected provider Workspaces list - List workspaces get - Retrieve a workspace update - Update a workspace WorkspaceSecurity list_domains - List verified domains create_domain - Add a domain delete_domain - Delete a domain verify_domain - Verify a domain get_ip_allowlist - Retrieve the IP allowlist update_ip_allowlist - Enable or disable the IP allowlist add_ip_range - Add an IP range delete_ip_range - Delete an IP range WorkspaceSettings get - Retrieve workspace settings update - Update workspace settings Server-sent event streaming Server-sent events are used to stream content from certain operations. These operations will expose the stream as Generator that can be consumed using a simple for loop. The loop will terminate when the server no longer has any events to send and closes the underlying connection.
The stream is also a Context Manager and can be used with the with statement and will close the underlying connection when the context is exited.
To change the default retry strategy for a single API call, simply provide a RetryConfig object to the call:
from orq_ai_sdk import Orq from orq_ai_sdk.utils import BackoffStrategy, RetryConfig import os with Orq( api_key=os.getenv("ORQ_API_KEY"), ) as orq: res = orq.deployments.invoke(key=" ", stream=False, identity={ "id": "contact_01ARZ3NDEKTSV4RRFFQ69G5FAV", "display_name": "Jane Doe", "email": "jane.doe@example.com", "metadata": [ { "department": "Engineering", "role": "Senior Developer", }, ], "logo_url": "https://example.com/avatars/jane-doe.jpg", "tags": [ "hr", "engineering", ], }, documents=[ { "text": "The refund policy allows customers to return items within 30 days of purchase for a full refund.", "metadata": { "file_name": "refund_policy.pdf", "file_type": "application/pdf", "page_number": 1.0, }, }, { "text": "Premium members receive free shipping on all orders over $50.", "metadata": { "file_name": "membership_benefits.md", "file_type": "text/markdown", }, }, ], RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False)) assert res is not None # Handle response print(res) If you'd like to override the default retry strategy for all operations that support retries, you can use the retry_config optional parameter when initializing the SDK:
from orq_ai_sdk import Orq, models import os with Orq( api_key=os.getenv("ORQ_API_KEY"), ) as orq: res = None try: res = orq.deployments.invoke(key=" ", stream=False, identity={ "id": "contact_01ARZ3NDEKTSV4RRFFQ69G5FAV", "display_name": "Jane Doe", "email": "jane.doe@example.com", "metadata": [ { "department": "Engineering", "role": "Senior Developer", }, ], "logo_url": "https://example.com/avatars/jane-doe.jpg", "tags": [ "hr", "engineering", ], }, documents=[ { "text": "The refund policy allows customers to return items within 30 days of purchase for a full refund.", "metadata": { "file_name": "refund_policy.pdf", "file_type": "application/pdf", "page_number": 1.0, }, }, { "text": "Premium members receive free shipping on all orders over $50.", "metadata": { "file_name": "membership_benefits.md", "file_type": "text/markdown", }, }, ]) assert res is not None # Handle response print(res) except models.OrqError as e: # The base class for HTTP error responses print(e.message) print(e.status_code) print(e.body) print(e.headers) print(e.raw_response) # Depending on the method different errors may be thrown if isinstance(e, models.ErrorResponse): print(e.data.message) # str print(e.data.code) # Optional[int] print(e.data.details) # Optional[List[Any]] Error Classes Primary error:
* Check the method documentation to see if the error is applicable.
The default server can be overridden globally by passing a URL to the server_url: str optional parameter when initializing the SDK client instance. For example:
For example, you could specify a header for every request that this sdk makes as follows:
from orq_ai_sdk import Orq import httpx http_client = httpx.Client(headers={"x-custom-header": "someValue"}) s = Orq(client=http_client) or you could wrap the client with your own custom logic:
import httpx2 httpx2.alias_httpx() from orq_ai_sdk import Orq s = Orq() An SDK can also be generated against httpx2 directly, so it depends on the fork instead of httpx, by setting python.httpClientLibrary: httpx2 in gen.yaml.
The Orq class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a context manager and reuse it across the application.
from orq_ai_sdk import Orq import os def main(): with Orq( api_key=os.getenv("ORQ_API_KEY"), ) as orq: # Rest of application here... pass # Or when using async: async def amain(): async with Orq( api_key=os.getenv("ORQ_API_KEY"), ) as orq: # Rest of application here... pass Debugging You can setup your SDK to emit debug logs for SDK requests and responses.
You can pass your own logger class directly into your SDK.
from orq_ai_sdk import Orq import logging logging.basicConfig(level=logging.DEBUG) s = Orq(debug_logger=logging.getLogger("orq_ai_sdk")) You can also enable a default debug logger by setting an environment variable ORQ_DEBUG to true.
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
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.
None of the files in this release were uploaded with provenance metadata.
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.




