Orq AI SDK

4.7.7 · active · verified Thu Apr 16

The `orq-ai-sdk` is a Python Client SDK for the Orq API, enabling developers to build, ship, and optimize LLM applications at scale. It provides a type-safe interface for interacting with Orq.ai's platform functionalities, including prompt management, model routing, RAG (Retrieval Augmented Generation), observability, and evaluation. The SDK supports both synchronous and asynchronous operations and is actively maintained with regular updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the `Orq` client using an API key from an environment variable and then invoke a deployment. Ensure `ORQ_API_KEY` is set in your environment. Replace `"your-deployment-key"` with an actual deployment key from your Orq.ai workspace. The client supports context managers for proper resource management, especially in long-lived applications.

import os
from orq_ai_sdk import Orq

# Initialize the Orq client with your API key
# Get your API key from the Orq.ai dashboard (Workspace Settings -> API Keys)
# It's recommended to use environment variables for API keys.

def main():
    with Orq(
        api_key=os.environ.get("ORQ_API_KEY", ""),
        # environment="production", # Optional: specify environment
        # identity_id=123 # Optional: link requests to an identity
    ) as client:
        try:
            # Example: Invoke a deployment
            # Replace "your-deployment-key" with the actual key from your Orq.ai deployment
            generation = client.deployments.invoke(
                key="your-deployment-key",
                context={
                    "user_id": "test_user", 
                    "session_id": "session_123"
                },
                inputs={
                    "query": "What is the capital of France?"
                },
                metadata={
                    "source": "quickstart"
                },
            )
            if generation.choices:
                print("Generated content:", generation.choices[0].message.content)
            else:
                print("No content generated.")

        except Exception as e:
            print(f"An error occurred: {e}")

if __name__ == "__main__":
    main()

view raw JSON →