Prompt Library Overview
The Prompt Library is the central place to manage every prompt your agent depends on. Version them, iterate on new versions from the Opik UI or the SDK, and link the exact version that produced a trace.
Why use the Prompt Library
When prompts are hardcoded, every change requires a code change to update. There is no history of what changed, no way to roll back quickly, and no clean way to compare alternative versions.
The Prompt Library gives you version control for the prompts that drive your agent. Push them to Opik once, and from there you can compare versions, fetch a specific one, or always follow the latest.
Key features
- Project-scoped prompts — Every prompt lives inside a project, so different agents can have prompts with the same name without colliding.
- Versioning by
v1,v2,v3, … — Each change creates a new immutable, sequentially numbered version. Fetch a specific one with theversionselector (e.g."v3"), or omit it to fetch the most recent. - Text and chat prompts — Version simple string templates as well as multi-message chat templates with
{{variable}}substitution. - Agent configuration in one place — Prompts live alongside the rest of an agent configuration (model, parameters, tools) so a trace links back to the exact bundle that produced it.
- Python and TypeScript SDKs — Create, fetch, and render prompts from either language.
How it works
- Define your prompts — Use
create_prompt/create_chat_promptto send your prompts to Opik. This becomesv1. - Fetch at runtime — Call
get_prompt/get_chat_promptfrom inside a tracked function. The SDK returns the requested version and links it to the trace automatically. - Iterate from the UI — Edit the prompt and save a new version. If your code doesn’t pin a
version, the agent picks up the new version on its next fetch — otherwise update your code to point at the new version name.
Next steps
- Getting started — Add the Prompt Library to your code in minutes
- Text and chat prompts — When to use each, multimodal content, template engines, and searching
- Version control — Create and compare versions
- Prompt playground — Test prompt variants side-by-side across models, without writing code