Skip to main content

Models

Create a Model

Creates a new custom model for the workspace. Provider credentials in the configuration are encrypted using the workspace encryption key before being persisted.
import orq_ai_sdk
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.models.create(configuration={

    }, display_name="Albert_Emmerich25", has_functions=False, id="<id>", input_cost=2127.52, metadata=orq_ai_sdk.ModelMetadata(
        is_private=False,
    ), model_developer="<value>", model_family="<value>", model_id="<id>", model_type="<value>", output_cost=5446, parameters=[
        {
            "config": {

            },
            "name": "<value>",
            "parameter": "<value>",
            "parameter_type": "<value>",
        },
    ], provider="<value>")

    # Handle response
    print(res)

Create Autorouter

Creates an autorouter model that routes between a strong and economical source model based on the requested profile. Both source models must already exist for the workspace and be marked autorouter-eligible in master data.
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.models.create_autorouter(economical_model="<value>", key="<key>", strong_model="<value>")

    # Handle response
    print(res)

Update Autorouter

Re-configures an autorouter model. Each of key/strong_model/economical_model/profile falls back to the existing value when omitted. Changing the key enforces uniqueness and rewrites PRICING_KV.
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.models.update_autorouter(id="<id>")

    # Handle response
    print(res)

Create AWS Bedrock

Registers an AWS Bedrock inference profile as a custom model for the workspace. Credentials are resolved at request time via either the integration reference or pod-identity - nothing is stored with the model.
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.models.create_aws_bedrock(auth_mode="<value>", display_name="Shanon.Wintheiser", model_developer="<value>", model_id="<id>", region="<value>")

    # Handle response
    print(res)

Validate AWS Bedrock

Performs a live Bedrock Converse probe to verify the inference profile ARN and credentials, then best-effort enriches the response from known system models.
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    orq.models.validate_aws_bedrock(auth_mode="<value>", inference_profile_arn="<value>", region="<value>")

    # Use the SDK ...

Update AWS Bedrock

Updates an AWS Bedrock custom model. ARN changes are format-validated (live AWS validation lives in the dedicated validate endpoint). Configuration and metadata are spread-merged. Parameters are replaced only when the request produces a non-empty list.
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.models.update_aws_bedrock(id="<id>")

    # Handle response
    print(res)

Azure Foundry Deployments

Lists Azure Foundry deployments under the given base_url and joins each entry with the Orq master-data row. Only OpenAI-developed deployments in succeeded state with chat/completion/embedding/vision model types are returned.
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.models.azure_foundry_deployments(api_key="<value>", base_url="https://admired-overcoat.info", provider="<value>")

    # Handle response
    print(res)

Import LiteLLM

Bulk-imports a list of LiteLLM model definitions into the workspace model garden.
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.models.import_litellm(request=[
        {
            "litellm_params": {
                "merge_reasoning_content_in_choices": False,
                "model": "CX-9",
                "use_in_pass_through": False,
                "use_litellm_proxy": False,
            },
            "model_info": {
                "db_model": True,
                "id": "<id>",
                "key": "<key>",
                "litellm_provider": "<value>",
                "mode": "<value>",
            },
            "model_name": "<value>",
        },
    ])

    # Handle response
    print(res)

List LiteLLM

Fetches the list of models from the LiteLLM instance configured for the workspace. Requires a stored LiteLLM integration.
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.models.list_litellm()

    # Handle response
    print(res)

Create OpenAI Like

Creates a custom model backed by any OpenAI-compatible endpoint. The handler probes the target API with the supplied credentials before persisting the model.
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.models.create_openai_like(api_key="<value>", base_url="https://guilty-cap.org/", display_name="Richard.Beatty45", model_id="<id>", model_type="<value>", region="<value>")

    # Handle response
    print(res)

Update OpenAI Like

Updates an OpenAI-compatible custom model. Live-re-probes the target API when base_url or model_id changes, using the stored encrypted api_key. Metadata is merged (existing preserved, new overrides).
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.models.update_openai_like(id="<id>", display_name="Verlie82", model_type="<value>", region="<value>")

    # Handle response
    print(res)

Validate a Model

Validates a provider endpoint by performing a minimal live probe. Currently supports Azure OpenAI. Response includes the resolved region, whether the model is known to Orq, and either the full model document or a synthesized default.
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    orq.models.validate(api_key="<value>", provider="<value>")

    # Use the SDK ...

Create Vertex

Registers a Google Vertex AI model as a custom model for the workspace. The service account credentials are probed against Vertex AI with a minimal GenerateContent call before persisting.
import orq_ai_sdk
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.models.create_vertex(configuration=orq_ai_sdk.VertexConfiguration(
        location="<value>",
        model_configuration=orq_ai_sdk.VertexModelConfiguration(
            capabilities=orq_ai_sdk.VertexCapabilities(
                structured_output=True,
                support_tool_calling=False,
                vision=True,
            ),
            id="<id>",
            input_cost=6100.6,
            output_cost=4860.06,
            parameters=orq_ai_sdk.VertexParameters(
                max_tokens=orq_ai_sdk.VertexParamRangeInt(
                    max=816266,
                    min=370614,
                ),
                temperature=orq_ai_sdk.VertexParamRange(
                    max=1989.61,
                    min=8564.64,
                ),
                top_p=orq_ai_sdk.VertexParamRange(
                    max=3250.24,
                    min=8051.01,
                ),
            ),
        ),
        project_id="<id>",
        service_account={
            "key": "<value>",
            "key1": "<value>",
            "key2": "<value>",
        },
    ), display_name="Birdie_Bailey-Abernathy")

    # Handle response
    print(res)

Delete a Model

Deletes a custom model from the workspace. System models cannot be deleted. Returns 200 with an explanatory message if the model is a system model or is still referenced by experiments.
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    orq.models.delete(id="<id>")

    # Use the SDK ...

Update a Model

Updates a custom model. Only fields present in the request body are modified, except for metadata and parameters, which are fully replaced when present (preserved from the legacy handler’s behavior).
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.models.update(id="<id>")

    # Handle response
    print(res)

Enable a Model

Adds the model to the workspace’s enabled set. Idempotent - re-enabling an already-enabled model returns 204 with no state change.
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    orq.models.enable(model_id="<id>")

    # Use the SDK ...

Disable a Model

Removes the model from the workspace’s enabled set. Idempotent - disabling an already-disabled model returns 204.
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    orq.models.disable(model_id="<id>")

    # Use the SDK ...

List Models

Lists all models available through the AI Router. Returns each model in OpenAI-compatible shape with its provider, ID, and creation timestamp.
from orq_ai_sdk import Orq
import os

with Orq(
    api_key=os.getenv("ORQ_API_KEY", ""),
) as orq:

    res = orq.models.list()

    # Handle response
    print(res)