Bootstrap a new OSDK Python application

On this page, we will walk through the process of creating a Python application that uses the OSDK. The example below can be used with many Python frameworks, such as Flask ↗, Streamlit ↗, and Jupyter ↗.

1: Prerequisites

Create a Developer Console application

Follow the steps listed in the create a new Developer Console application page.

Set up your token

Export your token in your local environment. Below is an example using a sample personal access token, but you can generate a longer-lived one in the Developer Console. This token should not be checked into source control because it is your personal access token.

Copied!
1 export FOUNDRY_TOKEN=<YOUR-TOKEN-FROM-GETTING-STARTED-PAGE>

Check Python version

The Python SDK requires a Python version >=3.10 and <3.15. To check what version of Python you are using, enter the command below:

Copied!
1 python3 --version

Optional: Set up certificate

If your organization requires certificates for network traffic, you may need to tell Python where that certificate lives.

Copied!
1 2 export SSL_CERT_FILE="/path/to/my.crt" export REQUESTS_CA_BUNDLE="/path/to/my.crt"

If pip install continues to fail with certificate verify failed errors after you set the certificate environment variables, your certificate authority (CA) trust configuration is incomplete. Correct that configuration rather than bypassing verification.

To temporarily confirm that certificate trust is the cause, run the installation once with the --trusted-host flag. This flag disables certificate verification for the specified host, so use it only for diagnosis and never in production or automated environments.

Copied!
1 pip install <YOUR-PACKAGE-NAME> --upgrade --extra-index-url "https://:$FOUNDRY_TOKEN@<INDEX-URL>" --trusted-host <YOUR-FOUNDRY-HOSTNAME>

Replace <YOUR-FOUNDRY-HOSTNAME> with your Foundry environment hostname. If the installation succeeds with the flag, the missing trust chain is confirmed. Work with your network administrator to add the complete CA certificate chain to the file referenced by SSL_CERT_FILE and REQUESTS_CA_BUNDLE. Then reinstall without --trusted-host.

2: Install the latest version of your SDK

Run the following command to install the latest version of the SDK, replacing any < > with your application-specific value that can be found on your application Overview page.

Copied!
1 pip install <YOUR-PACKAGE-NAME> --upgrade --extra-index-url "https://:$FOUNDRY_TOKEN@<INDEX-URL>"

Develop your frontend application

In your application, initialize the Foundry client and start developing.

Copied!
1 2 3 4 5 6 7 8 9 10 import os from <PACKAGE-NAME> import FoundryClient from <PACKAGE-NAME>.core.api import UserTokenAuth auth = UserTokenAuth(hostname="<YOUR-FOUNDRY-URL>", token=os.environ["FOUNDRY_TOKEN"]) client = FoundryClient(auth=auth, hostname="<YOUR-FOUNDRY-URL>") object = client.ontology.objects.<ANY-OBJECT> print(object.take(1))