> For clean Markdown of any page, append `.md` to the page URL. > For a complete documentation index, see https://docs.sarvam.ai/llms.txt. > For full documentation content in one file, see https://docs.sarvam.ai/llms-full.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.sarvam.ai/_mcp/server. # How to get repeatable results using `seed` > Reduce output variation with best-effort seeded sampling The `seed` parameter enables **best-effort repeatability** for the same prompt and settings. It does not guarantee identical output. Use it to reduce variation during testing and debugging, while allowing for outputs to change between requests or model updates. ### What it does: * The same seed and request parameters can reduce output variation. * Identical requests can still produce different outputs. * Model or serving updates can change results produced by a previously used seed. * This feature is currently in **Beta**. > **Note** > > In recent testing, setting `seed` did not measurably reduce output variation compared to > omitting it, repeated requests with the same seed varied as much as requests with no > seed at all. Treat `seed` as best-effort only, and do not rely on it for reproducibility > until this is confirmed fixed. --- ### Format and Range: | Property | Value Type | Range | | -------- | ---------- | ----------------------------------------------------- | | `seed` | Integer | `>= -9223372036854776000` to `<= 9223372036854776000` | 👉 Typically, values like `42`, `1234`, or any stable number will work fine. ### When to use `seed`: | Use Case | Why use it? | | ----------------------------- | -------------------------------------------- | | Regression testing | Reduce unrelated variation between runs | | Demo apps or tutorials | Make outputs more predictable | | A/B testing with fixed inputs | Limit sampling variation during comparison | | QA pipelines | Compare behavior without assuming exact text | --- First, install the SDK: ```bash pip install -Uqq sarvamai ``` Then use the following Python code: ```python from sarvamai import SarvamAI # Initialize the SarvamAI client with your API key client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY") # Example: Using `seed` to repeat responses response = client.chat.completions( model="sarvam-105b", messages=[ {"role": "system", "content": "You are a poetry assistant."}, {"role": "user", "content": "Write a short poem about the moon."} ], seed=12345 # Best-effort repeatability; identical output is not guaranteed ) # Receive assistant's reply as output print(response.choices[0].message.content) ``` > Reduce output variation with best-effort seeded sampling