Type-safe Python SDK for the Bluejay platform — testing, evaluation, and monitoring for conversational AI agents.
Project description
bluejay-sdk
Developer-friendly & type-safe Python SDK specifically catered to leverage bluejay-sdk API.
Summary
Bluejay: Type-safe Python SDK for the Bluejay platform — testing, evaluation, and monitoring for conversational AI agents.
Table of Contents
SDK Installation
[!NOTE] Python version upgrade policy
Once a Python version reaches its official end of life date, a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated.
The SDK can be installed with uv, pip, or poetry package managers.
uv
uv is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.
uv add bluejay-sdk
PIP
PIP is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
pip install bluejay-sdk
Poetry
Poetry is a modern tool that simplifies dependency management and package publishing by using a single pyproject.toml file to handle project metadata and dependencies.
poetry add bluejay-sdk
Shell and script usage with uv
You can use this SDK in a Python shell with uv and the uvx command that comes with it like so:
uvx --from bluejay-sdk python
It's also possible to write a standalone Python script without needing to set up a whole project like so:
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "bluejay-sdk",
# ]
# ///
from bluejay import Bluejay
sdk = Bluejay(
# SDK arguments
)
# Rest of script here...
Once that is saved to a file, you can run it with uv run script.py where
script.py can be replaced with the actual file name.
IDE Support
PyCharm
Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.
SDK Example Usage
Example
# Synchronous Example
from bluejay import Bluejay
import os
with Bluejay(
api_key=os.getenv("BLUEJAY_API_KEY", ""),
) as b_client:
res = b_client.schedules.create_schedule(simulation_id="<id>", schedule={
"frequency": "cron",
"expression": "<value>",
})
# Handle response
print(res)
The same SDK client can also be used to make asynchronous requests by importing asyncio.
# Asynchronous Example
import asyncio
from bluejay import Bluejay
import os
async def main():
async with Bluejay(
api_key=os.getenv("BLUEJAY_API_KEY", ""),
) as b_client:
res = await b_client.schedules.create_schedule_async(simulation_id="<id>", schedule={
"frequency": "cron",
"expression": "<value>",
})
# Handle response
print(res)
asyncio.run(main())
Authentication
Per-Client Security Schemes
This SDK supports the following security scheme globally:
| Name | Type | Scheme | Environment Variable |
|---|---|---|---|
api_key |
apiKey | API key | BLUEJAY_API_KEY |
To authenticate with the API the api_key parameter must be set when initializing the SDK client instance. For example:
from bluejay import Bluejay
import os
with Bluejay(
api_key=os.getenv("BLUEJAY_API_KEY", ""),
) as b_client:
res = b_client.schedules.create_schedule(simulation_id="<id>", schedule={
"frequency": "cron",
"expression": "<value>",
})
# Handle response
print(res)
Available Resources and Operations
Available methods
AgentWorkflow
- get_workflow_summary - Get Workflow Summary
- patch_workflow_node - Patch Workflow Node
- delete_workflow_node - Delete Workflow Node
- add_workflow_node - Add Workflow Node
- add_workflow_edge - Add Workflow Edge
- delete_workflow_edge - Delete Workflow Edge
Agents
- add_agent - Add Agent
- update_agent - Update Agent
- update_agent_by_external_id - Update Agent By External Id
- get_agent - Get Agent
- get_agent_by_external_id - Get Agent By External Id
- get_all_agents - Get All Agents
- delete_agent - Delete Agent
CallLogs
- retrieve_call_logs - Retrieve Call Logs
- retrieve_call_log - Retrieve Call Log
- delete_call_log - Delete Call Log
- update_log - Update Log
Communities
- create_community - Create Community
- get_community - Get Community
- delete_community - Delete Community
- get_communities - Get Communities
- update_community - Update Community
- add_digital_humans_to_community - Add Digital Humans To Community
- remove_digital_humans_from_community - Remove Digital Humans From Community
Conversations
- end_conversations - End Conversations
CustomMetrics
- create_custom_metric - Create Custom Metric
- create_custom_metrics - Create Custom Metrics
- get_custom_metric - Get Custom Metric
- delete_custom_metric - Delete Custom Metric
- get_custom_metrics - Get Custom Metrics
get_custom_metrics_by_agent- Get Custom Metrics By Agent :warning: Deprecated- update_custom_metric - Update Custom Metric
- bulk_update_custom_metrics - Bulk Update Custom Metrics
- bulk_delete_custom_metrics - Bulk Delete Custom Metrics
- generate_custom_metrics - Generate Custom Metrics
DigitalHumans
- create_digital_human - Create Digital Human
- bulk_create_digital_humans - Bulk Create Digital Humans
- get_digital_human - Get Digital Human
- delete_digital_human - Delete Digital Human
- get_digital_human_by_test_name - Get Digital Human By Test Name
- get_digital_humans_by_simulation - Get Digital Humans By Simulation
- get_all_digital_humans - Get All Digital Humans
- update_digital_human - Update Digital Human
- bulk_delete_digital_humans - Bulk Delete Digital Humans
- list_custom_background_noises - List Custom Background Noises
- create_custom_background_noise - Create Custom Background Noise
- update_custom_background_noise - Update Custom Background Noise
- delete_custom_background_noise - Delete Custom Background Noise
- generate_objectives_endpoint - Generate Objectives Endpoint
- generate_intent_summary_endpoint - Generate Intent Summary Endpoint
- generate_prompt_summary_endpoint - Generate Prompt Summary Endpoint
- generate_formatted_transcript_endpoint - Generate Formatted Transcript Endpoint
- generate_digital_humans - Generate Digital Humans
ElevenLabs
- list_elevenlabs_agents - List Elevenlabs Agents
- list_elevenlabs_branches - List Elevenlabs Branches
Evaluate
- evaluate - Evaluate
Folders
- create_folder - Create Folder
- get_all_folders - Get All Folders
- get_folder - Get Folder
- delete_folder - Delete Folder
- move_agent_to_folder - Move Agent To Folder
- update_folder - Update Folder
- get_agents_by_folder - Get Agents By Folder
HTTPTextAgent
- queue_http_simulation_run - Queue Http Simulation Run
- send_http_text_message - Send Http Text Message
PhoneNumbers
- get_phone_numbers - Get Phone Numbers
- add_phone_number - Add Phone Number
- release_phone_number - Release Phone Number
RetrieveSimulationResults
- retrieve_simulation_results - Retrieve Simulation Results
- retrieve_simulation_result - Retrieve Simulation Result
ScenarioBuilder
- create_workflow_v2 - Create Workflow V2
- list_workflows_v2 - List Workflows V2
- validate_workflow_definition - Validate Workflow Definition
- duplicate_workflow_v2 - Duplicate Workflow V2
- get_workflow_v2 - Get Workflow V2
- update_workflow_v2 - Update Workflow V2
- delete_workflow_v2 - Delete Workflow V2
Schedules
- create_schedule - Create Schedule
- update_schedule - Update Schedule
- delete_schedule - Delete Schedule
- get_schedule - Get Schedule
- list_schedules - List Schedules
Simulations
- delete_simulation - Delete Simulation
- update_simulation - Update Simulation
- get_simulation - Get Simulation
- create_simulation - Create Simulation
- get_all_simulations - Get All Simulations
- get_simulations_by_agent - Get Simulations By Agent
- get_simulation_runs - Get Simulation Runs
- queue_simulation_run - Queue Simulation Run Endpoint
TextSimulations
- queue_sms_simulation_run - Queue Sms Simulation Run
Traces
- get_trace - Get Trace
- get_span - Get Span
- get_all_traces - Get All Traces
Translation
- translate_transcript - Translate a call transcript
Retries
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply provide a RetryConfig object to the call:
from bluejay import Bluejay
from bluejay.utils import BackoffStrategy, RetryConfig
import os
with Bluejay(
api_key=os.getenv("BLUEJAY_API_KEY", ""),
) as b_client:
res = b_client.schedules.create_schedule(simulation_id="<id>", schedule={
"frequency": "cron",
"expression": "<value>",
},
RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
# Handle response
print(res)
If you'd like to override the default retry strategy for all operations that support retries, you can use the retry_config optional parameter when initializing the SDK:
from bluejay import Bluejay
from bluejay.utils import BackoffStrategy, RetryConfig
import os
with Bluejay(
retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
api_key=os.getenv("BLUEJAY_API_KEY", ""),
) as b_client:
res = b_client.schedules.create_schedule(simulation_id="<id>", schedule={
"frequency": "cron",
"expression": "<value>",
})
# Handle response
print(res)
Error Handling
BluejayError is the base class for all HTTP error responses. It has the following properties:
| Property | Type | Description |
|---|---|---|
err.message |
str |
Error message |
err.status_code |
int |
HTTP response status code eg 404 |
err.headers |
httpx.Headers |
HTTP response headers |
err.body |
str |
HTTP body. Can be empty string if no body is returned. |
err.raw_response |
httpx.Response |
Raw HTTP response |
err.data |
Optional. Some errors may contain structured data. See Error Classes. |
Example
from bluejay import Bluejay, errors
import os
with Bluejay(
api_key=os.getenv("BLUEJAY_API_KEY", ""),
) as b_client:
res = None
try:
res = b_client.schedules.create_schedule(simulation_id="<id>", schedule={
"frequency": "cron",
"expression": "<value>",
})
# Handle response
print(res)
except errors.BluejayError as e:
# The base class for HTTP error responses
print(e.message)
print(e.status_code)
print(e.body)
print(e.headers)
print(e.raw_response)
# Depending on the method different errors may be thrown
if isinstance(e, errors.HTTPValidationError):
print(e.data.detail) # Optional[List[models.ValidationError]]
Error Classes
Primary errors:
BluejayError: The base class for HTTP error responses.HTTPValidationError: Validation Error. Status code422.
Less common errors (5)
Network errors:
httpx.RequestError: Base class for request errors.httpx.ConnectError: HTTP client was unable to make a request to a server.httpx.TimeoutException: HTTP request timed out.
Inherit from BluejayError:
ResponseValidationError: Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via thecauseattribute.
Server Selection
Override Server URL Per-Client
The default server can be overridden globally by passing a URL to the server_url: str optional parameter when initializing the SDK client instance. For example:
from bluejay import Bluejay
import os
with Bluejay(
server_url="https://api.getbluejay.ai",
api_key=os.getenv("BLUEJAY_API_KEY", ""),
) as b_client:
res = b_client.schedules.create_schedule(simulation_id="<id>", schedule={
"frequency": "cron",
"expression": "<value>",
})
# Handle response
print(res)
Custom HTTP Client
The Python SDK makes API calls using the httpx HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.
Depending on whether you are using the sync or async version of the SDK, you can pass an instance of HttpClient or AsyncHttpClient respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls.
This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of httpx.Client or httpx.AsyncClient directly.
For example, you could specify a header for every request that this sdk makes as follows:
from bluejay import Bluejay
import httpx
http_client = httpx.Client(headers={"x-custom-header": "someValue"})
s = Bluejay(client=http_client)
or you could wrap the client with your own custom logic:
from bluejay import Bluejay
from bluejay.httpclient import AsyncHttpClient
import httpx
class CustomClient(AsyncHttpClient):
client: AsyncHttpClient
def __init__(self, client: AsyncHttpClient):
self.client = client
async def send(
self,
request: httpx.Request,
*,
stream: bool = False,
auth: Union[
httpx._types.AuthTypes, httpx._client.UseClientDefault, None
] = httpx.USE_CLIENT_DEFAULT,
follow_redirects: Union[
bool, httpx._client.UseClientDefault
] = httpx.USE_CLIENT_DEFAULT,
) -> httpx.Response:
request.headers["Client-Level-Header"] = "added by client"
return await self.client.send(
request, stream=stream, auth=auth, follow_redirects=follow_redirects
)
def build_request(
self,
method: str,
url: httpx._types.URLTypes,
*,
content: Optional[httpx._types.RequestContent] = None,
data: Optional[httpx._types.RequestData] = None,
files: Optional[httpx._types.RequestFiles] = None,
json: Optional[Any] = None,
params: Optional[httpx._types.QueryParamTypes] = None,
headers: Optional[httpx._types.HeaderTypes] = None,
cookies: Optional[httpx._types.CookieTypes] = None,
timeout: Union[
httpx._types.TimeoutTypes, httpx._client.UseClientDefault
] = httpx.USE_CLIENT_DEFAULT,
extensions: Optional[httpx._types.RequestExtensions] = None,
) -> httpx.Request:
return self.client.build_request(
method,
url,
content=content,
data=data,
files=files,
json=json,
params=params,
headers=headers,
cookies=cookies,
timeout=timeout,
extensions=extensions,
)
s = Bluejay(async_client=CustomClient(httpx.AsyncClient()))
Resource Management
The Bluejay class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a context manager and reuse it across the application.
from bluejay import Bluejay
import os
def main():
with Bluejay(
api_key=os.getenv("BLUEJAY_API_KEY", ""),
) as b_client:
# Rest of application here...
# Or when using async:
async def amain():
async with Bluejay(
api_key=os.getenv("BLUEJAY_API_KEY", ""),
) as b_client:
# Rest of application here...
Debugging
You can setup your SDK to emit debug logs for SDK requests and responses.
You can pass your own logger class directly into your SDK.
from bluejay import Bluejay
import logging
logging.basicConfig(level=logging.DEBUG)
s = Bluejay(debug_logger=logging.getLogger("bluejay"))
You can also enable a default debug logger by setting an environment variable BLUEJAY_DEBUG to true.
Development
Maturity
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
Contributions
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
SDK Created by Speakeasy
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bluejay_sdk-0.3.6.tar.gz.
File metadata
- Download URL: bluejay_sdk-0.3.6.tar.gz
- Upload date:
- Size: 154.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a873cc604f21e4d7b4c9bb28b1a8b9633b7377bc4954940ac25b9bc79073c08f
|
|
| MD5 |
681fb41af00993de9cb991fdaf4371ee
|
|
| BLAKE2b-256 |
d29ef6b2e157766751946906442f8741a5bb363e42ef8809f6f73206adc9809c
|
File details
Details for the file bluejay_sdk-0.3.6-py3-none-any.whl.
File metadata
- Download URL: bluejay_sdk-0.3.6-py3-none-any.whl
- Upload date:
- Size: 305.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9246158071e4036d00fa306b8af3ee74bbdf6c72783f8b66abb63ab38db95d5b
|
|
| MD5 |
13891011ffea54e98877acfcd8deabb3
|
|
| BLAKE2b-256 |
b8f59cfa865ae8d9e50d87d6f94df8c4867da698f2d20114c478e25615e717fb
|