# Set up with your coding agent

Add Latent to your project by pasting one prompt into Claude Code, Codex, Cursor or another coding agent.

Your coding agent can add Latent to a project in one pass. The change is small: install one package, read two environment variables and add one call at startup.

## The prompt

Paste this into your coding agent while it works in your project:

```text
Add Latent hallucination scoring to this project.
Read https://runlatent.ai/docs/quickstart and https://runlatent.ai/docs/sdk before changing any code.
1. Install the runlatent package from PyPI (pip install runlatent) and add it to the project's dependencies.
2. Read LATENT_API_URL and LATENT_API_KEY from the project's environment configuration. Add both to the example env file if there is one, with LATENT_API_URL=https://app.runlatent.ai. Do not write a real key into the code.
3. In the app's entry point, import runlatent and call runlatent.auto_instrument() once at startup, before any OpenAI, Anthropic or Google GenAI client is created, including an openai client pointed at another endpoint by base_url.
4. If LATENT_API_KEY is not set, stop here and ask me to create a key at https://app.runlatent.ai and add it to the project's environment myself. Never ask for the key in this chat.
5. Run the app once so it makes one model call, then call runlatent.flush() and print runlatent.stats(). Confirm that "posted" is at least 1 and "failed" is 0.
Change nothing else.
```

## What the agent changes

1. **A dependency.** `runlatent` joins your requirements. It brings no dependencies of its own.
2. **Two environment variables.** `LATENT_API_URL` is `https://app.runlatent.ai`, and `LATENT_API_KEY` is your key, shown once on the console's setup page after you first sign in. It lasts one year. The key stays in your environment and never in the code.
3. **One call at startup.** `runlatent.auto_instrument()` covers every OpenAI, Anthropic and Google GenAI client the process creates.
4. **A check.** With a key set, one model call, then `runlatent.flush()` and `runlatent.stats()` show the answer was posted and none failed. Without a key, the agent stops and asks you to add one, so the key never passes through the chat.

Nothing else in the app changes: the agent does not wrap calls, add retries or touch your prompts.

## Review the change

Before you merge, check three things in the diff:

- The key is read from the environment.
- `auto_instrument()` runs once, at startup.
- No other code changed.

## Best practices

- Ask the agent to stop after the check, so a first run never reaches production traffic by surprise.
- Leave `LATENT_API_URL` and `LATENT_SIDECAR_URL` unset in environments where you don't want answers sent. Nothing is sent without one of them.
- If your team prefers explicit wiring, ask the agent to use the per-client wrappers in the [Python SDK reference](/docs/sdk#per-client-wrappers) instead of `auto_instrument()`.

---
Docs index: https://runlatent.ai/llms.txt
