We recommend to use our official client libraries to interact with the orq.ai API

Github

Our SDKs are available on Github:



Installation

# The SDK can be installed with either pip or poetry package managers.
# PIP

pip install orq-ai-sdk

# Poetry

poetry add orq-ai-sdk
# The SDK can be installed with either npm, pnpm, bun or yarn package managers.
# NPM

npm add @orq-ai/node

# PNPM

pnpm add @orq-ai/node

# Bun

bun add @orq-ai/node

# Yarn

yarn add @orq-ai/node zod

# Note that Yarn does not install peer dependencies automatically. You will need
# to install zod as shown above.

Usage

You can get your workspace API keys from the settings section in your orq.ai workspace. https://my.orq.ai/<workspace>/settings/developers

Initialize the orq.ai client with your API key:

import os

from orq_ai_sdk import Orq

client = Orq(
	 api_key=os.environ.get("ORQ_API_KEY", "__API_KEY__"),
 	 environment="production",
   # optionally initiate the contact_id for the session
   contact_id=2025
)
import { Orq } from "@orq-ai/node";

const client = new Orq({
  apiKey: 'orq-api-key',
  environment: 'production',
  // Optionally initiate the contactId for the session
  contactId: 2025
});

Deployments

The Deployments API delivers text outputs, images, or tool calls based on the configuration established within orq.ai for your deployments. Additionally, this API supports streaming. It is highly recommended that you use the code snippets from the orq.ai Admin panel to ensure ease of use and minimize errors.


Invoke a deployment

invoke()

generation = client.deployments.invoke(
    key="customer_service",
    context={"environments": "production", "country": "NLD"},
    inputs={"firstname": "John", "city": "New York"},
    metadata={"customer_id": "Qwtqwty90281"},
)

print(generation.choices[0].message.content)
const deployment = await client.deployments.invoke({
  key: 'customer_service',
  context: { environments: 'production', country: 'NLD' },
  inputs: { firstname: 'John', city: 'New York' },
  metadata: { customer_id: 'Qwtqwty90281' },
});

console.log(deployment?.choices[0].message.content);

📘

Learn more about Invoke() reading the Python and Node.js docs.

Deployments can also be streamed:

Read more about using the SDK to interact with the Deployments API with Python and Node.js.


Other Resources and Operations

Read more on the Github SDK Documentation for all Resources and Operations: