Connect

Connect to Dyff

Use Client to connect to Dyff Cloud at api.dyff.io:

Warning

Use of Dyff Cloud is currently restricted to research collaborators. Email contact@dsri.org to obtain an API key.

>>> from dyff.client import Client
>>> client = Client(api_key="XXXXXX")

Use Client with the endpoint parameter to connect to another Dyff instance:

>>> from dyff.client import Client
>>> client = Client(
...     api_key="XXXXXX",
...     endpoint="https://dyff.example.com/v0",
... )

When using a local cluster, use Client with a custom endpoint and add insecure=True to allow self-signed certificates:

Warning

The insecure flag should not be used in production.

>>> from dyff.client import Client
>>> client = Client(
...     api_key="XXXXXX",
...     endpoint="https://api.dyff.local/v0",
...     insecure=True,
... )

A subset of Dyff functionality is available without a Dyff cluster using DyffLocalPlatform.

>>> from dyff.audit.local import DyffLocalPlatform
>>> client = DyffLocalPlatform()

Artifacts save to ./dyff-outputs by default. Pass storage_root to use another directory:

>>> client = DyffLocalPlatform(storage_root="/path/to/outputs")

Test the client

You should now be able to execute API operations. For example, you can list all of the Models in the system that your API token grants access to:

>>> client.models.query()
[<list of dyff.schema.platform.Model objects>]

Troubleshooting

401 Unauthorized error

You have not provided a valid API token. If you’re providing credentials via environment variables (as we recommend), check that the variable is set correctly.

403 Forbidden error

You have provided a valid API token, but it does not grant you permission to take the action you’ve taken. By default, many operations – like .create() and .data() – are permitted only for resources in your account.