Python SDK

Events

Publish an event to a channel, then search what landed, every parameter, and the shapes that come back.

client.events has two methods: publish (POST /event) and search (GET /events).

Publish

publish takes three positional arguments, the identifier, the payload, and the channel UUID, and everything else by keyword.

from axonpush import AxonPush, EventType

with AxonPush() as client:
  event = client.events.publish(
      "web_search",
      {"query": "AI agent frameworks"},
      "b0f1c2d3-4e5f-6071-8293-a4b5c6d7e8f9",
      agent_id="researcher",
      event_type=EventType.AGENT_TOOL_CALL_START,
      metadata={"tool_name": "web_search"},
  )
  if event:
      print(event.event_id, event.status)

The identifier is the event’s name. It does not have to be unique across events, many log records sharing a logger name all persist as separate rows.

Parameters

ParameterTypeRequiredWhat it does
identifierstryesEvent name, e.g. "web_search" or "task.started". Positional.
payloaddictyesEvent body. Passed through redaction. Positional.
channel_idstryesTarget channel UUID. Positional.
agent_idstrnoWhich agent emitted this.
event_typeEventType or strnoDefaults to custom server-side.
metadatadictnoFree-form map, redacted on the same rules as payload.
trace_idstrnoTrace UUID. One is created and installed on the current context when omitted.
span_idstrnoSpan id. Generated from the trace context when omitted.
parent_span_idstrnoParent span id, for span linking.
dedup_keystrnoIdempotency key. Send the same key on a retry so the ingest pipeline collapses the duplicate.
prompt_idstrnoPrompt registry id. Lands in metadata as gen_ai.prompt.id.
prompt_version_idstrnoPrompt version. Lands in metadata as gen_ai.prompt.version.

The environment comes from the client (AxonPush(environment="prod")); there is no per-call override.

The API also accepts occurredAt (the original source time, which retries should preserve) and expiresAt (an earlier content expiry, which can shorten but never extend the 30-day retention window). publish in 0.0.19 does not expose them; send them through the HTTP API if you need them.

What comes back

Ingest is asynchronous, so the response describes the accepted write, not the stored row:

FieldTypeMeaning
event_idstrServer-assigned event UUID.
statusstrIngest status of the accepted write.

The call returns None instead, rather than raising, when the API is unreachable and fail_open is left on. See fail-open.

Event types

from axonpush import EventType

EventType.AGENT_START            # "agent.start"
EventType.AGENT_END              # "agent.end"
EventType.AGENT_MESSAGE          # "agent.message"
EventType.AGENT_TOOL_CALL_START  # "agent.tool_call.start"
EventType.AGENT_TOOL_CALL_END    # "agent.tool_call.end"
EventType.AGENT_ERROR            # "agent.error"
EventType.AGENT_HANDOFF          # "agent.handoff"
EventType.AGENT_LLM_TOKEN        # "agent.llm.token"
EventType.AGENT_LOG              # "agent.log"
EventType.APP_LOG                # "app.log"
EventType.APP_SPAN               # "app.span"

EventType is a str enum, so the plain string works everywhere the enum does: event_type="agent.start". The backend accepts any string; leave event_type unset to get custom.

app.log and agent.log are what the logging integrations emit; app.span is what the OpenTelemetry exporter emits.

search spans the whole organisation and takes every filter by keyword. All filters are AND-ed; omit one to match everything.

results = client.events.search(
    event_type="agent.error",
    since="2026-08-01T00:00:00Z",
    q="timeout",
    limit=50,
)

for ev in results.events:
    print(ev.occurred_at, ev.event_type, ev.trace_id)
ParameterTypeWhat it does
since / untilstrISO 8601 bounds, since inclusive, until exclusive.
limitintPage size.
app_idstrRestrict to one app.
channel_idstrRestrict to one channel.
environment_idstrRestrict to one environment UUID.
event_typestrOne canonical event type.
sourcestrIngest source: app, sentry or otlp.
statusstrEvent status.
trace_idstrOnly events in this trace.
agent_id / agent_namestrOnly events from this agent.
tool_namestrTool name (gen_ai.tool.name).
semantic_kindstragent, tool, llm, retriever, db, http or log.
qstrCase-insensitive free-text match over event fields.
attr_key / attr_valuestrMatch one attribute key and value.

The response is a SearchEventsOutputBody whose events list holds stored event records.

The stored event

Records returned by search and by traces.get() are richer than the publish acknowledgement. Every record has event_id, org_id, app_id, channel_id, event_type, source, created_at, occurred_at and payload_spilled. Beyond those, the backend fills in what it could derive:

  • Identity and linkage, agent_id, agent_name, trace_id, span_id, parent_span_id, session_id, user_id, environment_id.
  • Content, payload, metadata, attributes, resource_attributes.
  • Model attribution, request_model, response_model, provider_name, operation_name, finish_reason, semantic_kind, tool_name.
  • Token and cost accounting, input_tokens, output_tokens, total_tokens, reasoning_tokens, cache_read_tokens, cache_write_tokens, cost_usd, cost_source.
  • Timing and outcome, duration_ms, ttft_ms, status, error_type, error_message, service_name.

These are optional: a hand-published custom event leaves most of them unset.