DiracX Client Library

0.0.12 · active · verified Sat Apr 11

The DiracX Python Client Library, currently at version 0.0.12, provides a Pythonic interface for interacting with the DiracX AI platform. It allows developers to integrate advanced AI functionalities into their applications by accessing features like model listing and AI task creation. The library is under active development, with frequent pre-1.0 releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the DiracX client using API keys from environment variables and fetch a list of available AI models. Ensure 'DIRACX_API_KEY' and 'DIRACX_API_SECRET' are configured in your environment.

import os
from diracx_client import DiracXClient

# Ensure DIRACX_API_KEY and DIRACX_API_SECRET are set as environment variables
# For local development, you might use a .env file and python-dotenv.
# e.g., os.environ['DIRACX_API_KEY'] = 'your_key'
#       os.environ['DIRACX_API_SECRET'] = 'your_secret'

api_key = os.environ.get("DIRACX_API_KEY", "")
api_secret = os.environ.get("DIRACX_API_SECRET", "")

if not api_key or not api_secret:
    print("Error: DIRACX_API_KEY and DIRACX_API_SECRET environment variables must be set.")
    # In a real application, you might raise an exception or handle this more gracefully.
    exit(1)

# Initialize the DiracXClient
client = DiracXClient(api_key=api_key, api_secret=api_secret)

# Example: Fetch available models
try:
    models_response = client.models.list_all()
    print("Successfully fetched models.")
    if models_response.data:
        print(f"First model ID: {models_response.data[0].id}")
        print(f"First model Name: {models_response.data[0].name}")
    else:
        print("No models found.")
except Exception as e:
    print(f"Error fetching models: {e}")

view raw JSON →