> For the complete documentation index, see [llms.txt](https://docs.layerlens.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.layerlens.ai/6.-build-wire-your-code/workflow.md).

# Build (workflow)

Stage 2 — Build. Wire your code or agent to emit traces Stratix can ingest, and develop with evaluation-driven feedback from the start.

Stage 2. Now that you've picked a model in [Select](/6.-build-wire-your-code/workflow.md), wire your code to emit **traces** — the data Stratix needs to grade what your AI did. The Build stage is where you instrument your application AND iterate on the AI feature with evaluation feedback in the loop.

## The question this stage answers

*"Can Stratix see what my AI is doing, and am I building toward something I can evaluate?"*

## What to do

1. **Pick an instrumentation strategy.**

* **SDK trace ingest** — call `client.traces.create(...)` after each AI call (or batch)
* **Framework integration** — if your framework has a Stratix integration, wire it in (see [Integrations](/6.-build-wire-your-code/migration.md))
* **OTel-style** — emit OpenTelemetry-like spans and post them as a trace

2. **Capture the whole chain.** A trace with only the top-level call is grading-friendly but useless for root-cause. Capture every span — every tool call, every retrieval, every nested LLM call.
3. **Annotate with tags.** `production`, `ab-test-v2`, `customer-tier-X` — make filtering tractable later.
4. **Test the ingest.** Send a single trace; confirm it appears in Premium → Traces.
5. **Iterate with evaluation in the loop.** As you build, run small evaluation passes against representative data so quality feedback lands while the code is still in flight, not at the end.

## What you'll have at the end

* Traces flowing into Stratix from your application
* A trace set you can grade with scorers and judges
* An evaluation feedback loop running alongside development

## Sample code

```python
from layerlens import Stratix
client = Stratix()

client.traces.create(
 id="trace-1",
 name="answer-question",
 inputs={"prompt": prompt_text},
 outputs={"response": response_text},
 spans=[
 {"name": "retrieval", "kind": "tool", "inputs": {...}, "outputs": {...}},
 {"name": "llm", "kind": "llm", "model": "claude-opus-4-7", "inputs": {...}, "outputs": {...}}
 ],
 tags={"environment": "production", "feature": "support-bot"}
)
```

## Where to next

* [Observe →](/6.-build-wire-your-code/workflow.md)
* [Concept: Traces and spans](/6.-build-wire-your-code/traces-and-spans.md)
* [Stratix Premium — Traces](/7.-observe-see-whats-happening/traces.md)
* [Integrations](/6.-build-wire-your-code/migration.md)
