Skip to main content

Pattern: Direct API

This example uses the Reflect SDK at its most explicit level - no decorators, no context managers. You call each step yourself, which makes it the best starting point for understanding how Reflect works.
Reviews don’t have to happen immediately. You can defer a trace and review it later in bulk via the dashboard or the API.

Prerequisites

Install dependencies:

Full example

interactive_feedback_cli.py

Run it

How it works

1

Connect to Reflect

ReflectClient authenticates with your API key and ties all traces to a project.
2

Augment the task with memories

Before calling the LLM, ask Reflect for relevant past experiences. It returns the original task plus a memory-augmented version you can pass directly to the model.
3

Solve with an LLM

Pass augmented.augmented_task as the user message so the model sees relevant context from past runs.
4

Review the answer

You decide whether the answer was correct. Three options:
5

Store the trace

create_trace_and_wait submits the trace and blocks until Reflect has processed it.When review_result is "pass" or "fail", Reflect immediately generates a reflection and updates utility scores so better memories surface in future runs.When review_result is None (deferred), the trace is stored as-is and can be reviewed later from the dashboard.

Key concept: deferred reviews

Passing review_result=None stores the trace without triggering the learning loop. This is useful when:
  • You’re running a batch and want to review results in one go
  • A human reviewer needs to approve the answer asynchronously
  • You want to collect traces first and label them later
Deferred traces appear in the dashboard with a pending review status. You can review them there or via the API.