Skip to Content
GlossaryAPI Token - Glossary

API Token

Back to GlossaryDevelopment

Authentication credentials used to integrate Rhesis with your systems programmatically via the SDK or API.

Also known as: token, API key

Overview

API tokens provide secure authentication for programmatic access to Rhesis. Use them to integrate testing into your CI/CD pipelines, automate workflows, or build custom integrations.

Creating Tokens

  1. Visit https://app.rhesis.ai
  2. Sign up or log in to your account
  3. Navigate to your account settings
  4. Generate a new API key
  5. Copy and store securely (format: )

Using Tokens with the SDK

Environment Variables (Recommended):

bash
export RHESIS_API_KEY="rh-your-api-key"
export RHESIS_BASE_URL="https://api.rhesis.ai"  # optional

In Python Code:

python
import os
from rhesis.sdk.synthesizers import PromptSynthesizer
from rhesis.sdk.entities import TestSet

# Set API key
os.environ["RHESIS_API_KEY"] = "rh-your-api-key"

# Use SDK features
for test_set in TestSet().all():
      print(test_set)

# Generate tests
synthesizer = PromptSynthesizer(
      prompt="Generate tests for a customer support chatbot"
)
test_set = synthesizer.generate(num_tests=10)

Using the Connector:

python
from rhesis.sdk import RhesisClient, endpoint

client = RhesisClient(
      api_key="rh-your-api-key",
      project_id="your-project-id",
      environment="development"
)

@endpoint()
def chat(input: str, session_id: str = None) -> dict:
      return {"output": process_message(input), "session_id": session_id}

In CI/CD:

yaml
name: Run Rhesis Tests
env:
    RHESIS_API_KEY: ${{ secrets.RHESIS_API_KEY }}
run: |
    pip install rhesis-sdk
    python run_tests.py

Security Best Practices

  • Never commit tokens: Use environment variables or secrets managers
  • Rotate regularly: Update tokens periodically
  • Monitor usage: Review API usage in your account settings
  • Revoke unused: Delete tokens no longer needed
  • Secure storage: Use secret management tools in production

Documentation

Related Terms