Skip to main content

Python SDK for the IgniteIQ Vault API — query home services data from LLM agents

Project description

igniteiq-vault — Python SDK

Query home services business data from your LLM agents in three lines of Python.

from igniteiq import VaultClient

client = VaultClient(api_key="iq_live_...", org_slug="tapps")
result = client.query_sync({"measures": ["fact_jobs.total_revenue"]})

Installation

pip install igniteiq-vault

With optional LangChain integration:

pip install "igniteiq-vault[langchain]"

With optional LlamaIndex integration:

pip install "igniteiq-vault[llamaindex]"

Getting an API key

  1. Open Studio → your org → SettingsAPI Keys
  2. Click Generate key and copy the value (starts with iq_live_)
  3. Store it securely — it is shown only once

Quick start

Async (recommended)

import asyncio
from igniteiq import VaultClient

client = VaultClient(api_key="iq_live_...", org_slug="tapps")

async def main():
    # Structured query
    result = await client.query({
        "measures": ["fact_jobs.total_revenue", "fact_jobs.job_count"],
        "timeDimensions": [{
            "dimension": "fact_jobs.job_created_at",
            "dateRange": "last 30 days",
        }],
        "limit": 100,
    })
    print(result["data"])

    # Context snapshot (injects business context into LLM system prompt)
    ctx = await client.context(period="last_30_days")
    print(ctx["systemPromptFragment"])

    # Natural language query
    ans = await client.ask("What was our revenue last month?")
    print(ans["answer"], "—", ans["confidence"])

    # LLM tool definitions
    tools = await client.schema.tools("openai")

asyncio.run(main())

Sync (for scripts and non-async frameworks)

from igniteiq import VaultClient

client = VaultClient(api_key="iq_live_...", org_slug="tapps")

result = client.query_sync({
    "measures": ["fact_jobs.total_revenue"],
    "timeDimensions": [{
        "dimension": "fact_jobs.job_created_at",
        "dateRange": "last 30 days",
    }],
})
print(result["data"])

ctx = client.context_sync(period="last_30_days")
print(ctx["systemPromptFragment"])

ans = client.ask_sync("How many jobs were completed last week?")
print(ans["answer"])

Understanding queries

Vault uses a semantic layer (powered by Cube.dev). Every query is expressed in terms of measures and dimensions:

Concept Description Example
Measure An aggregated metric fact_jobs.total_revenue
Dimension A group-by attribute fact_jobs.business_unit_name
Time dimension A date/time filter fact_jobs.job_created_at
Filter A row-level filter {member: "...", operator: "equals", values: [...]}

Use client.schema.tools("openai") to get machine-readable definitions of every available measure and dimension.

LangChain integration

from igniteiq import VaultClient
from igniteiq.langchain import VaultTool
from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain_core.prompts import ChatPromptTemplate

client = VaultClient(api_key="iq_live_...", org_slug="tapps")
vault_tool = VaultTool(client=client)

llm = ChatOpenAI(model="gpt-4o")
prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a helpful business analyst for a home services company."),
    ("human", "{input}"),
    ("placeholder", "{agent_scratchpad}"),
])
agent = create_tool_calling_agent(llm, [vault_tool], prompt)
executor = AgentExecutor(agent=agent, tools=[vault_tool])

result = executor.invoke({"input": "What was our revenue last month?"})
print(result["output"])

Using raw tool definitions for function calling

import openai

# Get OpenAI-format tool definitions from the Vault schema
tools_resp = await client.schema.tools("openai")
openai_tools = tools_resp["tools"]

response = openai.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "What was revenue last month?"}],
    tools=openai_tools,
)

LlamaIndex integration

from igniteiq import VaultClient
from igniteiq.llamaindex import VaultDataSource
from llama_index.core import VectorStoreIndex

client = VaultClient(api_key="iq_live_...", org_slug="tapps")
source = VaultDataSource(client=client)

# Load context snapshot as LlamaIndex Documents
docs = source.load_data(period="last_30_days")
print(docs[0].text[:300])

# Build a query engine over the context
index = VectorStoreIndex.from_documents(docs)
query_engine = index.as_query_engine()
response = query_engine.query("Summarise our financial performance.")
print(response)

Error handling

from igniteiq import VaultClient, VaultError

client = VaultClient(api_key="iq_live_...", org_slug="tapps")

try:
    result = await client.query({"measures": ["fact_jobs.total_revenue"]})
except VaultError as e:
    print(f"Error {e.code} (HTTP {e.status}): {e}")
    # e.code: UNAUTHORIZED | FORBIDDEN | NOT_FOUND | RATE_LIMITED | BAD_REQUEST | API_ERROR

Division scoping

For multi-division organisations, scope requests to a specific division:

result = await client.query(
    {"measures": ["fact_jobs.total_revenue"]},
)

ctx = await client.context(period="last_30_days", division_slug="north-division")
ans = await client.ask("Revenue trend?", division_slug="north-division")

API reference

Full REST API reference: https://igniteiq.com/docs/sdk/api-reference

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

igniteiq_vault-0.1.0.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

igniteiq_vault-0.1.0-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file igniteiq_vault-0.1.0.tar.gz.

File metadata

  • Download URL: igniteiq_vault-0.1.0.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for igniteiq_vault-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6e7f713038fb81d4cd21822dd9a8031153f364c35cf7b7d571c166d029aee54f
MD5 7238973ca6d3f1e23bfbabd5f9829114
BLAKE2b-256 686fff15bbce909bdc7b2a9ed5bd08090cf38df83eeb02844a67026d6e70a116

See more details on using hashes here.

File details

Details for the file igniteiq_vault-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: igniteiq_vault-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for igniteiq_vault-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4586dcf3c29f42a81e1f30f34347726be94f9f5261ec8a48724b764c45c641a7
MD5 119151122674d86baa3d78fec90daf06
BLAKE2b-256 5d5b34576fff52e3a883e633e269c70f3a71f1362be356995ac3010b3b1b4f81

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page