No project description provided
Project description
Credal Python Library
The Credal Python library provides convenient access to the Credal API from Python.
Documentation
Docs for the API endpoints available through the SDK can be found in our API Reference.
Reference
A full reference of the SDK is available here.
Installation
pip install --upgrade credal
Usage
from credal.client import CredalApi
client = CredalApi(
api_key="YOUR_API_KEY",
)
client.copilots.send_message(
message="Is Credal SOC 2 compliant?",
user_email="jack@credal.ai",
)
Self Hosted
client = CredalApi(
api_key="YOUR_API_KEY",
base_url="https://<custom-domain>/api",
)
Async Client
from credal.client import AsyncCredalApi
client = AsyncCredalApi(
api_key="YOUR_API_KEY",
)
Exception Handling
All errors thrown by the SDK will be subclasses of ApiError.
import credal
...
try:
client.copilots.send_message(...)
except credal.core.ApiError as e: # Handle all errors
print(e.status_code)
print(e.body)
Advanced
Timeouts
By default, requests time out after 60 seconds. You can configure this with a timeout option at the client or request level.
from credal.client import CredalApi
client = CredalApi(
...,
# All timeouts are 20 seconds
timeout=20.0,
)
# Override timeout for a specific method
client.copilots.send_message(..., {
timeout_in_seconds=20.0
})
Retries
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long as the request is deemed retriable and the number of retry attempts has not grown larger than the configured retry limit (default: 2).
A request is deemed retriable when any of the following HTTP status codes is returned:
Use the max_retries request option to configure this behavior.
client.copilots.send_message(..., {
max_retries=1
})
Custom HTTP client
You can override the httpx client to customize it for your use-case. Some common use-cases include support for proxies and transports.
import httpx
from credal.client import CredalApi
client = CredalApi(...,
http_client=httpx.Client(
proxies="http://my.test.proxy.example.com",
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
),
)
Project details
Release history Release notifications | RSS feed
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 credal-0.0.22.tar.gz.
File metadata
- Download URL: credal-0.0.22.tar.gz
- Upload date:
- Size: 41.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.18 Linux/5.15.0-1078-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52beed7011017434bc19127ed293072056e70c257e0c41e2078694b1bf856942
|
|
| MD5 |
35a0c22190dea9b2300ac455ab00b4f9
|
|
| BLAKE2b-256 |
137c0ff457ffff73842fe6884f21662558deddf9fa8f522f074bbd7904310f31
|
File details
Details for the file credal-0.0.22-py3-none-any.whl.
File metadata
- Download URL: credal-0.0.22-py3-none-any.whl
- Upload date:
- Size: 87.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.8.18 Linux/5.15.0-1078-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b66d8c964fdf6739f2fada35bb02ac82fa48adff4172342c65479df3885d82ef
|
|
| MD5 |
d604decc17e44d5edfed529f5a79959d
|
|
| BLAKE2b-256 |
f2baee1201b1f0a5f5e8edda6d95cab7a2b4fda327a68750a50acdd882d7d81e
|