API Reference
Complete API documentation for all Zetyra calculators. Each endpoint accepts JSON payloads and returns structured results with metadata.
Base URL
https://api.zetyra.com/api/v1
All endpoints require authentication via Bearer token in the Authorization header.
Endpoints
CUPED Calculator
POST /calculators/cuped
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| Sample Size Parameters | |||
| baseline_mean | float | Yes | Expected baseline mean of the metric |
| baseline_std | float | Yes | Expected standard deviation |
| mde | float | Yes | Minimum detectable effect as proportion (e.g., 0.05 for 5%) |
| alpha | float | No | Significance level, two-sided (default: 0.05) |
| power | float | No | Statistical power (default: 0.80) |
| Correlation Specification (provide correlation OR csv_data) | |||
| correlation | float | Conditional | Pre-computed Pearson correlation between covariate and outcome |
| csv_data | string | Conditional | Base64-encoded CSV for correlation calculation from data |
| metric_column | string | No | Column name for metric (default: "metric") |
| covariate_column | string | No | Single covariate column name (default: "covariate") |
| covariate_columns | string[] | No | List of covariate columns for multiple regression R² |
| Additional Options | |||
| daily_traffic | int | No | Daily traffic for days-saved estimation (default: 10000) |
| covariate_std | float | No | Covariate standard deviation for optimal coefficient calculation |
| metric_type | string | No | "continuous" | "proportion" (default: "continuous") |
Response Structure
{
"calculation_id": "uuid",
"results": {
"original_sample_size": 2453,
"adjusted_sample_size": 1252,
"sample_size_reduction_pct": 49.0,
"original_variance": 625.0,
"adjusted_variance": 318.75,
"variance_reduction_pct": 49.0,
"variance_reduction_factor": 0.51,
"correlation": 0.7,
"r_squared": 0.49,
"is_multiple_covariates": false,
"num_covariates": 1,
"regression_coefficients": null,
"optimal_coefficient": 0.7,
"original_duration_days": 49.1,
"adjusted_duration_days": 25.0,
"days_saved_estimate": 25,
"difference_score_variance": 375.0,
"difference_score_sample_size": 1471,
"ancova_advantage_pct": 14.9,
"confidence_interval": { "lower": 1180, "upper": 1340 },
"interpretation": "With a strong correlation...",
"warnings": null
},
"metadata": {
"computed_at": "2026-01-21T12:00:00.000Z",
"computation_time_ms": 12.5,
"parameters": { ... }
}
}Group Sequential Design
POST /calculators/gsd
Request Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| Core Design Parameters | |||
| alpha | float | 0.025 | One-sided Type I error rate; total alpha for two-sided tests |
| power | float | 0.90 | Statistical power (1 - β) |
| k | int | 3 | Number of analyses/looks |
| timing | float[] | Equal spacing | Information fractions [1/k, 2/k, ..., 1] |
| effect_size | float | 0.3 | Standardized effect size (Cohen's d) |
| Spending Functions | |||
| spending_function | string | OBrienFleming | "OBrienFleming" | "Pocock" | "HwangShihDecani" |
| beta_spending_function | string | Pocock | Futility spending function |
| Hypothesis Configuration | |||
| test_type | string | one_sided | "one_sided" | "two_sided" |
| hypothesis | string | superiority | "superiority" | "non_inferiority" |
| ni_margin | float | null | Non-inferiority margin (negative value, e.g., -0.05) |
| binding_futility | bool | false | If false, futility bounds are non-binding |
Response Structure
{
"max_sample_size": 846,
"expected_sample_size": 720,
"expected_sample_size_h0": 550,
"expected_sample_size_h1": 720,
"fixed_sample_size": 830,
"boundaries": {
"efficacy": [3.471, 2.454, 2.004],
"futility": [-0.251, 0.563, null]
},
"information_fractions": [0.333, 0.667, 1.0],
"cumulative_alpha_spent": [0.0005, 0.014, 0.05],
"cumulative_beta_spent": [0.019, 0.049, 0.10],
"stopping_probabilities": {
"h0": [0.0005, 0.014, 0.05],
"h1": [0.15, 0.45, 0.90]
},
"inflation_factor": 1.9,
"parameters": { ... }
}Bayesian Predictive Power (PPoS)
POST /calculators/bayesian
Request Parameters (Continuous Endpoint)
| Parameter | Type | Default | Description |
|---|---|---|---|
| outcome_type | string | Required | "continuous" for Normal-Normal model |
| prior_effect | float | 0.0 | Prior mean effect |
| prior_variance | float | 1.0 | Prior variance |
| interim_effect | float | 0.0 | Observed effect at interim |
| interim_variance | float | 0.1 | Variance of interim effect estimate |
| interim_n | int | 500 | Sample size at interim |
| final_n | int | 1000 | Planned final sample size |
| success_threshold | float | 0.95 | Posterior probability threshold for success |
| n_simulations | int | 10000 | Monte Carlo simulations |
| seed | int | 42 | Random seed for reproducibility |
Request Parameters (Binary Endpoint)
| Parameter | Type | Default | Description |
|---|---|---|---|
| outcome_type | string | Required | "binary" for Beta-Binomial model |
| prior_alpha | float | 1.0 | Beta prior α parameter |
| prior_beta | float | 1.0 | Beta prior β parameter |
| control_successes | int | 0 | Observed successes in control arm |
| control_n | int | 100 | Current control sample size |
| treatment_successes | int | 0 | Observed successes in treatment arm |
| treatment_n | int | 100 | Current treatment sample size |
| final_n | int | 1000 | Planned final total sample size |
Response Structure
{
"calculation_id": "uuid",
"results": {
"predictive_probability": 0.6421,
"posterior_mean": 0.22,
"posterior_variance": 0.0085,
"credible_interval": { "lower": 0.048, "upper": 0.392, "level": 0.95 },
"recommendation": "continue", // "stop_for_efficacy" | "continue" | "stop_for_futility"
"simulations_run": 10000,
"outcome_type": "continuous"
},
"metadata": { ... }
}Prior Elicitation
POST /calculators/prior-elicitation
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| method | string | Yes | "quantile_matching" | "ess_based" | "historical" |
| Quantile Matching | |||
| median | float | Conditional | Target median (0-1) |
| lower_bound | float | Conditional | Lower credible bound (0-1) |
| upper_bound | float | Conditional | Upper credible bound (0-1) |
| confidence | float | No | Credible interval level (default: 0.90) |
| ESS-Based | |||
| prior_mean | float | Conditional | Target mean (0-1) |
| ess | int | Conditional | Desired effective sample size |
| Historical Data | |||
| historical_events | int | Conditional | Number of events in historical data |
| historical_n | int | Conditional | Historical sample size |
| discount_factor | float | No | Power prior discount (default: 1.0) |
| seed | int | No | Random seed (default: 42) |
Response Structure
{
"calculation_id": "uuid",
"results": {
"alpha": 6.0,
"beta": 44.0,
"mean": 0.12,
"std": 0.045,
"mode": 0.104,
"variance": 0.00204,
"ess": 50.0,
"credible_interval": { "lower": 0.05, "upper": 0.20, "level": 0.90 },
"pdf_data": { "x": [...], "density": [...] },
"cdf_data": { "x": [...], "cdf": [...] },
"method": "quantile_matching",
"fit_quality": { "median_achieved": 0.119, "coverage_achieved": 0.897 }
},
"metadata": { ... }
}Bayesian Sample Size
POST /calculators/bayesian-sample-size
Request Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| prior_alpha | float | Required | Beta prior α (from Prior Elicitation) |
| prior_beta | float | Required | Beta prior β (from Prior Elicitation) |
| null_rate | float | Required | Null hypothesis threshold θ₀ |
| alternative_rate | float | Required | Design alternative θ₁ |
| decision_threshold | float | 0.95 | Posterior probability threshold γ |
| target_power | float | 0.80 | Target power (1-β) |
| target_type1_error | float | 0.05 | Maximum acceptable Type I error |
| n_simulations | int | 10000 | Monte Carlo simulations per evaluation |
| n_min, n_max, n_step | int | 10, 500, 5 | Search range parameters |
| compute_power_curve | bool | true | Whether to compute power curve |
| seed | int | 42 | Random seed for reproducibility |
Response Structure
{
"calculation_id": "uuid",
"results": {
"recommended_n": 85,
"operating_characteristics": {
"type1_error": 0.042,
"power": 0.823,
"n_simulations": 50000
},
"constraints_met": true,
"decision_rule": { "threshold": 0.95, "null_rate": 0.10, "interpretation": "..." },
"sensitivity": { "sensitivity_table": [...], "recommended_n": 85 },
"prior_impact": { "prior_ess": 50.0, "prior_weight": 0.37, "data_weight": 0.63 },
"power_curve": { "theta": [...], "power": [...] },
"search_results": { "n_evaluated": 99, "evaluations": [...] }
},
"metadata": { ... }
}Two-Arm Bayesian Design
POST /calculators/bayesian-two-arm
Request Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| Prior Parameters | |||
| treatment_prior_alpha | float | Required | Treatment arm Beta prior α |
| treatment_prior_beta | float | Required | Treatment arm Beta prior β |
| control_prior_alpha | float | Required | Control arm Beta prior α |
| control_prior_beta | float | Required | Control arm Beta prior β |
| Design Parameters | |||
| treatment_rate | float | Required | Expected treatment response rate |
| control_rate | float | Required | Expected control response rate |
| design_type | string | superiority | "superiority" | "non_inferiority" |
| ni_margin | float | 0.0 | Non-inferiority margin (negative) |
| comparison_type | string | difference | "difference" | "ratio" |
| allocation_ratio | float | 1.0 | N treatment / N control |
| decision_threshold | float | 0.95 | Posterior probability threshold |
| target_power | float | 0.80 | Target power |
| target_type1_error | float | 0.05 | Maximum Type I error |
| n_simulations | int | 5000 | Monte Carlo simulations (5k×5k inner sampling) |
| seed | int | 42 | Random seed |
Response Structure
{
"calculation_id": "uuid",
"results": {
"recommended_n_per_arm": 75,
"recommended_n_treatment": 75,
"recommended_n_control": 75,
"recommended_n_total": 150,
"operating_characteristics": { "type1_error": 0.041, "power": 0.825, "n_simulations": 15000 },
"constraints_met": true,
"decision_rule": { "design_type": "superiority", "comparison_type": "difference", "threshold": 0.95 },
"prior_impact": { "treatment_prior_ess": 50, "control_prior_ess": 50 },
"sensitivity": { "sensitivity_table": [...] }
},
"metadata": { ... }
}Historical Borrowing
POST /calculators/bayesian-borrowing
Request Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| method | string | Required | "power_prior" | "commensurate" | "map" |
| Historical Data | |||
| historical_events | int | Conditional | Events in historical study (power_prior/commensurate) |
| historical_n | int | Conditional | Sample size of historical study |
| discount_factor | float | 0.5 | Power prior discount (0-1) |
| tau | float | 1.0 | Commensurate prior τ parameter |
| studies | array | Conditional | List of {n_events, n_total} for MAP (min 2) |
| study_weights | float[] | null | Optional weights for MAP studies |
| robust_weight | float | 0.1 | MAP robust component weight |
| Base Prior & Analysis | |||
| base_prior_alpha | float | 1.0 | Base prior α |
| base_prior_beta | float | 1.0 | Base prior β |
| current_events | int | null | Current trial events (for conflict check) |
| current_n | int | null | Current trial n (for conflict check) |
| null_rate, alternative_rate | float | null | For sample size comparison |
| decision_threshold | float | 0.95 | Posterior probability threshold |
| n_simulations | int | 5000 | Monte Carlo simulations |
| seed | int | 42 | Random seed |
Response Structure
{
"calculation_id": "uuid",
"results": {
"effective_prior": { "alpha": 13.0, "beta": 89.0 },
"ess": { "total": 102.0, "from_historical": 100.0, "from_base_prior": 2.0 },
"prior_summary": { "mean": 0.127, "std": 0.033, "variance": 0.001089 },
"borrowing_details": {
"method": "power_prior",
"discount_factor": 0.5,
"effective_weight": 0.98,
"historical_data": { "events": 24, "n": 200, "rate": 0.12 }
},
"pdf_data": { "x": [...], "density": [...] },
"comparison": {
"with_borrowing": { "n_required": 85, "power": 0.82, "type1_error": 0.04 },
"without_borrowing": { "n_required": 120, "power": 0.80, "type1_error": 0.05 },
"comparison": { "sample_size_reduction": 35, "reduction_percentage": 29.2 }
},
"conflict_assessment": { "z_score": 0.21, "p_value": 0.83, "conflict_level": "none" },
"regulatory_notes": [...]
},
"metadata": { ... }
}Need more details?
Each calculator's methodology page includes full mathematical derivations.