Skip to main content
For detailed explanations, see the full documentation.

Install

pip install artanis

Initialize

from artanis import Artanis
artanis = Artanis(api_key="sk_...")  # or ARTANIS_API_KEY env var

Basic Trace

trace = artanis.trace("operation-name")
trace.input(question=q, context=ctx)
trace.output(response)

Multi-Stage Pipeline

trace = artanis.trace("rag-answer")

# Retrieve
chunks = retriever.search(query)
trace.state("chunks", [c.id for c in chunks])

# Generate
trace.input(prompt=prompt, model="gpt-5.1")
response = llm.generate(prompt)
trace.output(response)

Key Methods

MethodPurposeWhen to Use
trace.input(**kwargs)Record inputsData going into operation (question, prompt, parameters)
trace.output(value)Record final outputResult of operation (response, classification)
trace.state(name, value)Capture state for replayContext at runtime (doc IDs, config, guidelines)
trace.idGet trace IDLink feedback to traces

Feedback

artanis.feedback(
    trace_id="trace_abc123",
    rating="negative",              # or "positive" or 0.0-1.0
    correction={"answer": "..."},   # optional
    comment="User's note",          # optional
)

Common State to Capture

# Document corpus
trace.state("documents", [doc.id for doc in corpus])

# Retrieved chunks
trace.state("retrieved_chunks", [
    {"id": c.id, "score": c.score} for c in chunks
])

# Config that affects behavior
trace.state("config", {
    "model": "gpt-5.1",
    "guidelines": guidelines_text,
    "strictness": 0.8,
})

Environment Variables

VariableDefaultDescription
ARTANIS_API_KEYRequiredYour API key
ARTANIS_BASE_URLhttps://api.artanis.devAPI endpoint
ARTANIS_ENABLEDtrueEnable/disable tracing
ARTANIS_DEBUGfalseEnable debug logging

Error Handling

SDK never throws exceptions. If network fails or API is unreachable, traces are silently dropped.
# Safe even if Artanis is down
trace.output(response)  # Never throws

Disable in Tests

# Recommended
ARTANIS_ENABLED=false pytest
ARTANIS_ENABLED=false npm test