SDK

Here you'll get an overview of the Highflame Python Software Development Kit (SDK). This handy interface is how we recommend that you programmatically manage your Routes and Providers and integrate Highflame's security and governance features directly into your applications.

Installation

Get started by installing the SDK using pip:

pip install highflame

Initialization and Authentication

Use the SDK by initializing the Client. You'll need a Config object, which holds your credentials and the base URL of your Highflame deployment.

from highfame import Highflame, Config
import os
import dotenv

# Load environment variables
dotenv.load_dotenv()

try:
    config = Config(
        base_url="https://your-api-domain.com",   # Use appropriate environment URL
        highflame_api_key=os.getenv('HIGHFLAME_API_KEY'),
        llm_api_key=os.getenv("OPENAI_API_KEY")
    )
    client = Client(config)
    print('Successfully connected to Highflame Client')

except Exception as e:
    print(f"Failed to create client: {str(e)}")

Common Operations

Some common tasks you can perform with the SDK include:

Making Requests

Error Handling

Exception Handling

The SDK lists a set of custom exceptions, making error handling clear and predictable.

HighflameError

A base exception class for the Highflame client.

__init__(self, message: str, response: Optional[Response] = None) -> None

Parameters:

  • message: A string containing the error message.

  • response (Optional): A Response object that may contain additional information about the error.

__str__(self)

Return type: str Returns a string representation of the error.

Derived Exceptions

ProviderNotFoundError: A specified provider was not found in the Highflame service.

ProviderAlreadyExistsError: An attempt was made to create a provider that already exists in the Highflame service.

RouteNotFoundError: A specified route was not found in the Highflame service.

RouteAlreadyExistsError: An attempt was made to create a route that already exists in the Highflame service.

SecretNotFoundError: A specified secret was not found in the Highflame service.

SecretAlreadyExistsError: An attempt was made to create a secter that already exists in the Highflame service.

TemplateNotFoundError: A specified template was not found in the Highflame service.

TemplateAlreadyExistsError: An attempt was made to create a template that already exists in the Highflame service.

NetworkError: A network-related error while communicating with the Highflame service.

BadRequest: Highflame cannot process the request due to invalid syntax or corrupted data.

RateLimitExceededError: The rate limit for Highflame has been exceeded.

InternalServerError: Highflame encountered an internal server error.

MethodNotAllowedError: An attempted method is not allowed on the specified route or resource.

UnauthorizedError: The client is not authorized to perform the attempted action on the Highflame service.

ValidationError: There was a validation error with the provided data or request.

Last updated