For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
CommunityAPI StatusAPI PricingSign Up
DocumentationAPI ReferencesCookbookIntegrationDeveloper Tools
DocumentationAPI ReferencesCookbookIntegrationDeveloper Tools
  • Getting Started
    • Welcome
    • Quickstart
    • SDKs & Libraries
    • Building for Indian Languages
    • Models
    • Credits & Rate Limits
    • Errors & Troubleshooting
    • Talk to us
    • Pricing
    • Changelog
  • API Guides & Tutorials
      • Overview
        • List your chat messages
        • Control response randomness
        • Control response diversity
        • Adjust the model's thinking level
        • Improve response factual accuracy
        • Encourage new topics in response
        • Reduce repetition words or phrases in response
        • Get repeatable results
        • Control the response length
        • Control where the model stops
LogoLogo
CommunityAPI StatusAPI PricingSign Up
On this page
  • What it does:
  • Format and Range:
  • When to use seed:
API Guides & TutorialsChat CompletionHow-to

How to get repeatable results using seed

||View as Markdown|
Was this page helpful?
Previous

How to control the response length with max_tokens

Next
Built with

The seed parameter lets you make model outputs deterministic — meaning you’ll get the same output every time for the same prompt and settings.

Great for testing, debugging, or consistent experiences in production.

What it does:

  • When you pass a seed, the model uses that value to initialize its random number generator.
  • This allows it to sample deterministically — so the same prompt and settings will always produce the same result.
  • If you don’t pass a seed, the output will naturally vary on each request.
  • Note: This feature is currently in Beta — the system will make a best effort to sample deterministically when seed is used.

Format and Range:

PropertyValue TypeRange
seedInteger>= -9223372036854776000 to <= 9223372036854776000

👉 Typically, values like 42, 1234, or any stable number will work fine.

When to use seed:

Use CaseWhy use it?
Regression testingEnsure same outputs over time
Demo apps or tutorialsShow consistent results to all users
A/B testing with fixed inputsKeep output stable for comparison
QA pipelinesValidate expected model behavior

First, install the SDK:

$pip install -Uqq sarvamai

Then use the following Python code:

1from sarvamai import SarvamAI
2
3# Initialize the SarvamAI client with your API key
4client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")
5
6# Example: Using `seed` to repeat responses
7response = client.chat.completions(
8 model="sarvam-105b",
9 messages=[
10 {"role": "system", "content": "You are a poetry assistant."},
11 {"role": "user", "content": "Write a short poem about the moon."}
12 ],
13 seed=12345 # Ensures the same poem is returned every time (best effort)
14)
15
16# Receive assistant's reply as output
17print(response.choices[0].message.content)