Dakora Python SDK
Centralized prompt management with versioning, execution tracking, and analytics for production LLM applications.
Installation
pip install dakora
Quick Start
from dakora import Dakora
dakora = Dakora(api_key="dk_proj_...")
# Render versioned prompts
result = await dakora.prompts.render("greeting", {"name": "Alice"})
print(result.text) # "Hello Alice! How can I help you today?"
# Use with agents (automatic tracking)
message = result.to_message()
response = await agent.run(message)
# Query execution history & analytics
executions = await dakora.executions.list(
agent_id="support-bot"
)
All executions automatically tracked when using with dakora-agents.
Why Dakora?
- Centralized Prompts - Version control, A/B testing, instant updates without code deploys
- Automatic Tracking - Tokens, cost, latency tracked via OpenTelemetry
- Template Linkage - Know exactly which prompts are used in production
- Built-in Analytics - Query execution history by agent, session, template, cost
Template Management
# List prompts
prompts = await dakora.prompts.list(project_id="proj-123")
# Render with inputs
result = await dakora.prompts.render(
prompt_id="support-response",
inputs={"ticket": "...", "user": "Alice"}
)
# Version and metadata included
print(result.version) # "2.1.0"
print(result.prompt_id) # "support-response"
# Convert to agent message (auto-tracking)
message = result.to_message()
Execution Analytics
# Filter by agent, session, template
executions = await dakora.executions.list(
agent_id="support-bot", # Specific agent
session_id="session-789", # User conversation
prompt_id="greeting" # Template used
)
# Calculate costs
total_cost = sum(e["cost_usd"] for e in executions)
# Get full details
execution = await dakora.executions.get(execution_id="trace-456")
print(execution["conversation_history"])
print(execution["templates_used"])
Agent Integration
Automatic execution tracking with Microsoft Agent Framework:
pip install dakora[maf]
from dakora_agents.maf import DakoraIntegration
middleware = DakoraIntegration.setup(dakora)
client = AzureOpenAIChatClient(..., middleware=[middleware])
# Every agent call automatically tracked:
# - Tokens (input/output)
# - Cost ($)
# - Latency (ms)
# - Template linkage
# - Conversation history
Advanced Usage
Pagination:
result = await dakora.executions.list(
limit=50,
offset=100,
include_metadata=True
)
print(f"Showing {len(result['executions'])} of {result['total']}")
Singleton pattern:
# config.py
from dakora import Dakora
dakora = Dakora() # Uses DAKORA_API_KEY env var
# anywhere.py
from myapp.config import dakora
result = await dakora.prompts.render("greeting", {"name": "Alice"})
Environment variables:
DAKORA_API_KEY=dk_proj_...
DAKORA_BASE_URL=http://localhost:8000 # Optional
FastAPI example:
from fastapi import FastAPI
from dakora import Dakora
dakora = Dakora()
app = FastAPI()
@app.get("/greet/{name}")
async def greet(name: str):
result = await dakora.prompts.render("greeting", {"name": name})
return {"message": result.text}
Development
cd packages/client-python
pip install -e .
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dakora-0.2.0.tar.gz
(17.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
dakora-0.2.0-py3-none-any.whl
(19.1 kB
view details)
File details
Details for the file dakora-0.2.0.tar.gz.
File metadata
- Download URL: dakora-0.2.0.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
854dde38ed0e9ab84f2718a1ccc67befc66eb6a22b19438e218bfe94e443c5b4
|
|
| MD5 |
eebc40f255bd3cfa7a304a4bb8333f1a
|
|
| BLAKE2b-256 |
491ff0e243b49e37b6b22b3f8faed4ee8b6adb643e1ac112c9506602a228f06f
|
File details
Details for the file dakora-0.2.0-py3-none-any.whl.
File metadata
- Download URL: dakora-0.2.0-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f9481090d092858cd3ff6872a3a16c383f7a2781d1b0654d6265b7f886c5d96
|
|
| MD5 |
14967940f15009c2ed839a274a4cb414
|
|
| BLAKE2b-256 |
ffb123c7d3211fb4b9e1ef06695f59ea093dd30af1ddd0550f8a214c54da371d
|