Installation
Quick Start
Configuration
The client reads configuration from environment variables:Dakora Client
Dakora()
Initialize the Dakora client.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | None | None | API key. Falls back to DAKORA_API_KEY env var |
base_url | str | None | None | API base URL. Falls back to DAKORA_BASE_URL or https://api.dakora.io |
project_id | str | None | None | Project ID. Auto-resolved from API key if not provided |
client.close()
Close the HTTP client connection. Optional—usually not needed.
Prompts API
Access viaclient.prompts.
prompts.list()
List all prompt template IDs in your project.
Returns: list[str] — List of template IDs
Example:
prompts.get(prompt_id)
Get a prompt template by ID.
Parameters:
| Parameter | Type | Description |
|---|---|---|
prompt_id | str | Template ID |
dict — Template data including id, template, version, inputs, metadata
Example:
prompts.create(...)
Create a new prompt template.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
prompt_id | str | required | Unique template ID |
template | str | required | Template text (Jinja2 syntax) |
version | str | "1.0.0" | Semantic version |
description | str | None | None | Human-readable description |
inputs | dict | None | Input schema definition |
metadata | dict | None | Additional metadata |
dict — Created template data
Example:
prompts.render(...)
Render a template with input values.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
template_id | str | required | Template ID to render |
inputs | dict | required | Variables to substitute |
version | str | None | None | Specific version (defaults to latest) |
embed_metadata | bool | True | Embed tracking metadata in output |
RenderResult — Rendered template with metadata
Example:
RenderResult
The result of rendering a template. Attributes:| Attribute | Type | Description |
|---|---|---|
text | str | Rendered prompt text |
prompt_id | str | Template ID |
version | str | Template version used |
version_number | int | None | Numeric version for ordering |
inputs | dict | Input values used |
metadata | dict | Additional metadata |
Executions API
Access viaclient.executions. Query execution history for analytics and debugging.
executions.list(...)
List executions with optional filters.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
project_id | str | required | Project ID |
prompt_id | str | None | None | Filter by template ID |
agent_id | str | None | None | Filter by agent ID |
provider | str | None | None | Filter by provider (openai, anthropic) |
model | str | None | None | Filter by model |
has_templates | bool | None | None | Filter by template linkage |
min_cost | float | None | None | Filter by minimum cost (USD) |
start | str | None | None | Start date (ISO format) |
end | str | None | None | End date (ISO format) |
limit | int | 100 | Max results |
offset | int | 0 | Pagination offset |
list[dict] — List of executions
Example:
executions.get(...)
Get detailed execution data.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
project_id | str | required | Project ID |
trace_id | str | required | Execution trace ID |
span_id | str | None | None | Specific span ID |
include_messages | bool | False | Include full messages |
dict — Execution details
Example:
executions.get_timeline(...)
Get a normalized timeline view of an execution.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
project_id | str | required | Project ID |
trace_id | str | required | Execution trace ID |
compact_tools | bool | True | Collapse tool call/result pairs |
dict — Timeline with events list
Example:
executions.get_hierarchy(...)
Get the span hierarchy tree for an execution.
Parameters:
| Parameter | Type | Description |
|---|---|---|
project_id | str | Project ID |
trace_id | str | Execution trace ID |
dict — Hierarchical span tree
executions.get_related(...)
Get related traces (same session or parent/child).
Parameters:
| Parameter | Type | Description |
|---|---|---|
project_id | str | Project ID |
trace_id | str | Execution trace ID |
dict — Related traces information
Error Handling
The SDK raiseshttpx.HTTPStatusError for API errors: