Skip to main content
The Netra SDK exposes a prompts API that lets you:
  • Fetch managed prompts – Retrieve prompt versions by name and label from the Netra backend
  • Use labels for versioning – Target specific prompt versions such as "production", "staging", or any custom label
  • Integrate seamlessly – Drop fetched prompts directly into your LLM calls with zero boilerplate
This page shows how to use getPrompt to fetch and use your managed prompts.

Getting Started

The prompts client is initialized automatically when you call Netra.init. No additional flags are required as long as a valid OTLP endpoint and API key are configured.

getPrompt

Fetch a prompt version by name and label from the Netra backend.

Parameters

Return Value

getPrompt is async. Always await the call. Errors are logged and a safe fallback (null) is returned so your application keeps running.

Caching

By default, every getPrompt call hits the backend. Pass useCache: true to serve repeated lookups from an in-memory TTL cache.
Cache keys include both name and label, so production and staging versions are stored separately. Failed lookups (null) are not cached.

clearCache

Clear all cached prompt entries. The SDK also clears this cache when you call Netra.shutdown().
Returns: void

Configuration

Required

getPrompt relies on the OTLP endpoint and API key configured via Netra.init or environment variables.

Error Handling

getPrompt is designed to never throw. Errors are logged and null is returned so your application keeps running.
Common error scenarios and their log messages:

Complete Example

Next Steps

Last modified on December 4, 2026