Configuration

Four top-level functions configure the SDK. instrument() is required; optimize(), secure(), and eval() are optional paid features.

fluiq.instrument()

Python
fluiq.instrument(
    api_key  = "fl_...",          # required — or set FLUIQ_API_KEY env var
    endpoint = "https://...",     # optional — override for self-hosted
    version  = "v1",              # optional — pin for stable schema
)

The SDK reads FLUIQ_API_KEY and FLUIQ_API_ENDPOINT from the environment automatically, so instrument() can be called with no arguments in CI and production environments that set those variables.

fluiq.optimize()

Python
fluiq.optimize(
    mode = "cache",    # "cache" (default) | "observe"
)

modeTeam+ required

"cache" — full Redis caching enabled (default). "observe" — records what would be hits without intercepting calls. Must be called after instrument(). Fails open — if the backend is unreachable or the plan check fails, all LLM calls proceed normally.

fluiq.secure()

Python
fluiq.secure(
    mode = "warn",     # "warn" (default) | "block"
)

modeGrowth+ required

"warn" — post-call scan only; security metadata enriched on the trace (default). "block" — pre-call guard; raises FluiqSecurityError before the LLM call when a HIGH-risk prompt is detected. Must be called after instrument(). Fails open — a plan downgrade or endpoint outage never blocks your LLM calls.

fluiq.fetch_prompt()

Python
fluiq.fetch_prompt(
    slug  = "my-prompt",       # required — the unique identifier
    env   = "production",      # optional — "development" | "staging" | "production" (default)
)

slug / env

Fetches the environment snapshot promoted via the Prompts dashboard. Requires instrument() to have been called first (uses the same API key). Returns a prompt object with .template, .model, .variables, .version, and a .render(**kwargs) method for variable substitution.

fluiq.eval()

Python
fluiq.eval(
    thresholds   = {"hallucination": 0.8, "relevance": 0.7},
    metrics      = ["hallucination", "relevance", "toxicity"],
    mode         = "warn",          # "warn" (default) | "block"
    judge_model  = "gpt-4o-mini",
)

thresholds / metrics / mode / judge_model

Runs Fluiq's LLM-as-judge server-side after every LLM call. Supported metrics: hallucination, faithfulness, relevance, toxicity, coherence, completeness. "warn" logs when a score is below threshold (default). "block" raises FluiqEvalError before returning the response. Scores are stored in ClickHouse and visible in the dashboard's Quality column across all previous traces.