SDK

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

Installation

Get started by installing the SDK using pip:

pip install javelin_sdk

Initialization and Authentication

Use the SDK by initializing the Javelin client. You'll need a JavelinConfig object, which holds your credentials and the base URL of your Javelin deployment.

from javelin_sdk import JavelinClient, JavelinConfig
import os
import dotenv

# Load environment variables
dotenv.load_dotenv()

try:
    config = JavelinConfig(
        base_url="https://your-api-domain.com",   # Use appropriate environment URL
        javelin_api_key=os.getenv('JAVELIN_API_KEY'),
        llm_api_key=os.getenv("OPENAI_API_KEY")
    )
    client = JavelinClient(config)
    print('Successfully connected to Javelin 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.

JavelinClientError

A base exception class for the Javelin 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 Javelin service.

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

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

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

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

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

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

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

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

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

RateLimitExceededError: The rate limit for Javelin has been exceeded.

InternalServerError: Javelin 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 Javelin service.

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

What's Next?

  • Read about the Javelin CLI to learn how to manage resources on your terminal.

  • Learn in the Quick Start Guide for Agent Developers how to integrate the SDK into an application.

Last updated