A client library for accessing Circuit Breaker Labs API
Project description
Circuit Breaker Labs Python Client
[!Note] This project was automatically generated by OpenAPI Python Client from this OpenAPI spec.
Usage
First, create a client:
from circuit_breaker_labs import Client
client = Client(base_url="https://api.circuitbreakerlabs.ai/v1/")
Now build a request and use it when calling an endpoint
import os
from circuit_breaker_labs.api.evaluations import evaluate_system_prompt_post
from circuit_breaker_labs.models import EvaluateSystemPromptRequest
with client as client:
request = EvaluateSystemPromptRequest(
0.5,
3,
2,
os.getenv("SYSTEM_PROMPT"),
"anthropic/claude-3.7-sonnet",
)
run_tests_response = evaluate_system_prompt_post.sync(
client=client,
cbl_api_key=os.getenv("CBL_API_KEY"),
body=request,
)
Or do the same thing with an async version:
import os
from circuit_breaker_labs.api.evaluations import evaluate_system_prompt_post
from circuit_breaker_labs.models import EvaluateSystemPromptRequest
async with client as client:
request = EvaluateSystemPromptRequest(
0.5,
3,
2,
os.getenv("SYSTEM_PROMPT"),
"anthropic/claude-3.7-sonnet",
)
run_tests_response = evaluate_system_prompt_post.asyncio(
client=client,
cbl_api_key=os.getenv("CBL_API_KEY"),
body=request,
)
Things to know:
-
Every path/method combo becomes a Python module with four functions:
sync: Blocking request that returns parsed data (if successful) orNonesync_detailed: Blocking request that always returns aRequest, optionally withparsedset if the request was successful.asyncio: Likesyncbut async instead of blockingasyncio_detailed: Likesync_detailedbut async instead of blocking
-
All path/query params, and bodies become method arguments.
-
If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
-
Any endpoint which did not have a tag will be in
circuit_breaker_labs.api.default
Advanced customizations
There are more settings on the generated Client class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying httpx.Client or httpx.AsyncClient (depending on your use-case):
from circuit_breaker_labs import Client
def log_request(request):
print(f"Request event hook: {request.method} {request.url} - Waiting for response")
def log_response(response):
request = response.request
print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")
client = Client(
base_url="https://api.circuitbreakerlabs.ai/v1/",
httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
)
# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()
You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):
import httpx
from circuit_breaker_labs import Client
client = Client(
base_url="https://api.circuitbreakerlabs.ai/v1/",
)
# Note that base_url needs to be re-set, as would any shared cookies, headers, etc.
client.set_httpx_client(httpx.Client(base_url="https://api.circuitbreakerlabs.ai/v1/", proxies="http://localhost:8030"))
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 circuit_breaker_labs-1.0.3.tar.gz.
File metadata
- Download URL: circuit_breaker_labs-1.0.3.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdc81290cb0e482c8c2f9d31a6597e679a97700d959435141ac982917ff88f12
|
|
| MD5 |
702fe821f2f1e86ebcd98cbae79b8453
|
|
| BLAKE2b-256 |
35714a3e865656ffad5b589e9b5168960d2fc98185079be1839809d3e9b30aee
|
Provenance
The following attestation bundles were made for circuit_breaker_labs-1.0.3.tar.gz:
Publisher:
release.yml on circuitbreakerlabs/circuitbreakerlabs-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
circuit_breaker_labs-1.0.3.tar.gz -
Subject digest:
bdc81290cb0e482c8c2f9d31a6597e679a97700d959435141ac982917ff88f12 - Sigstore transparency entry: 732066508
- Sigstore integration time:
-
Permalink:
circuitbreakerlabs/circuitbreakerlabs-python@aff6299aa01cfdb59b176ddcab6088fc29bf5568 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/circuitbreakerlabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@aff6299aa01cfdb59b176ddcab6088fc29bf5568 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file circuit_breaker_labs-1.0.3-py3-none-any.whl.
File metadata
- Download URL: circuit_breaker_labs-1.0.3-py3-none-any.whl
- Upload date:
- Size: 26.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
372cf286f2dac34087dddd1d9d19103af40153a41ffc01a2540eef3a3f193fdc
|
|
| MD5 |
7cf05f1d8aa9d45b4ec55d5b8aa33bba
|
|
| BLAKE2b-256 |
eafded7e1550c634b6c8a88fd678e4cf4bbefa75c323a493db0aa29c2c7fb8e8
|
Provenance
The following attestation bundles were made for circuit_breaker_labs-1.0.3-py3-none-any.whl:
Publisher:
release.yml on circuitbreakerlabs/circuitbreakerlabs-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
circuit_breaker_labs-1.0.3-py3-none-any.whl -
Subject digest:
372cf286f2dac34087dddd1d9d19103af40153a41ffc01a2540eef3a3f193fdc - Sigstore transparency entry: 732066510
- Sigstore integration time:
-
Permalink:
circuitbreakerlabs/circuitbreakerlabs-python@aff6299aa01cfdb59b176ddcab6088fc29bf5568 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/circuitbreakerlabs
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@aff6299aa01cfdb59b176ddcab6088fc29bf5568 -
Trigger Event:
workflow_dispatch
-
Statement type: