Python
Get started with the Semilattice Python SDK
Get your API key
First, sign up for a Semilattice account and create an API key from the dashboard.
Install
Install the Semilattice Python SDK:
Initialise the client
Choose a population model
Navigate to the Populations page on your dashboard and select a population model to use. Copy the ID from the population’s metadata or from the address bar.
Click to copy the population model's ID
Simulate an answer
The answers.simulate
method simulates how this population would answer a question. Below, we are simulating how this population would respond to the question “Tech debt or unclear error messages, what’s worse?”.
Handle the response
The API will return immediately, but the simulation runs asynchronously. The initial response will have a status
field set to “Queued”:
Poll for results
The simulation will progress through these statuses: Queued
→ Running
→ Predicted
(or potentially Failed
). Predictions typically take less than a minute.
Poll for the result using the answer ID:
View the results
Once the simulation completes, the simulated_answer_percentages
field will contain the prediction results:
The simulated_answer_percentages
dictionary shows the predicted percentage of the population that would choose each answer option. In this example, 54.88% would choose “Tech debt” and 45.12% would choose “Unclear error messages”.
Next steps
Now that you’ve run your first simulation, explore the API Reference to learn about all available endpoints and options.